From 3638472a053a59ba6a0bbc6c356858e532a26bbd Mon Sep 17 00:00:00 2001 From: Dan Raper Date: Wed, 3 Jan 2024 16:34:38 +0000 Subject: [PATCH] Give OhmeChargeSchedulesCoordinator a kick to update --- custom_components/ohme/const.py | 2 +- custom_components/ohme/number.py | 9 +++++++++ custom_components/ohme/time.py | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/custom_components/ohme/const.py b/custom_components/ohme/const.py index b98528b..4f03218 100644 --- a/custom_components/ohme/const.py +++ b/custom_components/ohme/const.py @@ -1,7 +1,7 @@ """Component constants""" DOMAIN = "ohme" USER_AGENT = "dan-r-homeassistant-ohme" -INTEGRATION_VERSION = "0.3.0" +INTEGRATION_VERSION = "0.3.1" DATA_CLIENT = "client" DATA_COORDINATORS = "coordinators" diff --git a/custom_components/ohme/number.py b/custom_components/ohme/number.py index 44d80ce..06176c0 100644 --- a/custom_components/ohme/number.py +++ b/custom_components/ohme/number.py @@ -43,6 +43,15 @@ def __init__(self, coordinator, coordinator_schedules, hass: HomeAssistant, clie self._attr_device_info = client.get_device_info() + async def async_added_to_hass(self) -> None: + """When entity is added to hass.""" + await super().async_added_to_hass() + self.async_on_remove( + self.coordinator_schedules.async_add_listener( + self._handle_coordinator_update, None + ) + ) + @property def unique_id(self): """The unique ID of the switch.""" diff --git a/custom_components/ohme/time.py b/custom_components/ohme/time.py index 6eb85b4..265a113 100644 --- a/custom_components/ohme/time.py +++ b/custom_components/ohme/time.py @@ -45,6 +45,15 @@ def __init__(self, coordinator, coordinator_schedules, hass: HomeAssistant, clie "number.{}", "ohme_target_time", hass=hass) self._attr_device_info = client.get_device_info() + + async def async_added_to_hass(self) -> None: + """When entity is added to hass.""" + await super().async_added_to_hass() + self.async_on_remove( + self.coordinator_schedules.async_add_listener( + self._handle_coordinator_update, None + ) + ) @property def unique_id(self):