Skip to content

Commit

Permalink
Merge pull request #59 from iprak/add-warning-about-offline
Browse files Browse the repository at this point in the history
style: add warning if device goes offline
  • Loading branch information
iprak authored Aug 28, 2024
2 parents 5783288 + ab3bb5c commit e26d294
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion custom_components/sensi/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ def update(self, data_json: dict):
if state:
LOGGER.info("Updating %s (%s)", self.name, self.identifier)

new_offline = state.get("status") == "offline"

if not self.offline and new_offline:
LOGGER.warning("%s is now offline", self.name)
elif self.offline and not new_offline:
LOGGER.warning("%s is now back online", self.name)

self.offline = state.get("status") == "offline"
self.attributes[ATTR_OFFLINE] = self.offline

Expand All @@ -190,7 +197,7 @@ def update(self, data_json: dict):
else UnitOfTemperature.FAHRENHEIT
)
else:
LOGGER.info("Property 'display_scale' not found in data")
LOGGER.warning("Property 'display_scale' not found in data")

self.attributes[ATTR_POWER_STATUS] = state.get("power_status")
self.attributes[ATTR_WIFI_QUALITY] = state.get("wifi_connection_quality")
Expand Down

0 comments on commit e26d294

Please sign in to comment.