Skip to content

Commit

Permalink
update connection status and next refresh context listeners on update…
Browse files Browse the repository at this point in the history
… success
  • Loading branch information
rlippmann committed Mar 6, 2024
1 parent 067eb30 commit c5c45ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions custom_components/adtpulse/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
ALARM_CONTEXT = "Alarm"
ZONE_CONTEXT_PREFIX = "Zone "
ZONE_TROUBLE_PREFIX = " Trouble"
CONNECTION_STATUS_CONTEXT = "ConnectionStatus"
NEXT_REFRESH_CONTEXT = "NextRefresh"


class ADTPulseDataUpdateCoordinator(DataUpdateCoordinator):
Expand Down Expand Up @@ -80,6 +82,8 @@ def async_update_listeners(self) -> None:
self._listener_dictionary[
ZONE_CONTEXT_PREFIX + str(zones) + ZONE_TROUBLE_PREFIX
]()
for i in CONNECTION_STATUS_CONTEXT, NEXT_REFRESH_CONTEXT:
self._listener_dictionary[i]()
LOG.debug(
"%s: partial async_update_listeners took %s",
ADTPULSE_DOMAIN,
Expand Down
10 changes: 7 additions & 3 deletions custom_components/adtpulse/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

from .base_entity import ADTPulseEntity
from .const import ADTPULSE_DOMAIN
from .coordinator import ADTPulseDataUpdateCoordinator
from .coordinator import (
ADTPulseDataUpdateCoordinator,
CONNECTION_STATUS_CONTEXT,
NEXT_REFRESH_CONTEXT,
)
from .utils import get_gateway_unique_id

LOG = getLogger(__name__)
Expand Down Expand Up @@ -83,7 +87,7 @@ def __init__(self, coordinator: ADTPulseDataUpdateCoordinator):
site_name,
)

self._name = f"ADT Pulse Connection Status - Site: {site_name}"
self._name = CONNECTION_STATUS_CONTEXT
super().__init__(coordinator, self._name)

@property
Expand Down Expand Up @@ -169,7 +173,7 @@ def __init__(self, coordinator: ADTPulseDataUpdateCoordinator):
site_name,
)

self._name = f"ADT Pulse Next Refresh - Site: {site_name}"
self._name = NEXT_REFRESH_CONTEXT
super().__init__(coordinator, self._name)

@property
Expand Down

0 comments on commit c5c45ce

Please sign in to comment.