diff --git a/homeassistant/components/kostal_plenticore/helper.py b/homeassistant/components/kostal_plenticore/helper.py index cb43486dbe0..a91fb24aad7 100644 --- a/homeassistant/components/kostal_plenticore/helper.py +++ b/homeassistant/components/kostal_plenticore/helper.py @@ -12,7 +12,7 @@ from aiohttp.client_exceptions import ClientError from pykoplenti import ApiClient, ApiException, AuthenticationException from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP -from homeassistant.core import HomeAssistant +from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity import DeviceInfo @@ -171,7 +171,7 @@ class PlenticoreUpdateCoordinator(DataUpdateCoordinator[_DataT]): self._fetch: dict[str, list[str]] = defaultdict(list) self._plenticore = plenticore - def start_fetch_data(self, module_id: str, data_id: str) -> None: + def start_fetch_data(self, module_id: str, data_id: str) -> CALLBACK_TYPE: """Start fetching the given data (module-id and data-id).""" self._fetch[module_id].append(data_id) @@ -180,7 +180,7 @@ class PlenticoreUpdateCoordinator(DataUpdateCoordinator[_DataT]): async def force_refresh(event_time: datetime) -> None: await self.async_request_refresh() - async_call_later(self.hass, 2, force_refresh) + return async_call_later(self.hass, 2, force_refresh) def stop_fetch_data(self, module_id: str, data_id: str) -> None: """Stop fetching the given data (module-id and data-id).""" @@ -251,7 +251,7 @@ class PlenticoreSelectUpdateCoordinator(DataUpdateCoordinator[_DataT]): def start_fetch_data( self, module_id: str, data_id: str, all_options: list[str] - ) -> None: + ) -> CALLBACK_TYPE: """Start fetching the given data (module-id and entry-id).""" self._fetch[module_id].append(data_id) self._fetch[module_id].append(all_options) @@ -261,7 +261,7 @@ class PlenticoreSelectUpdateCoordinator(DataUpdateCoordinator[_DataT]): async def force_refresh(event_time: datetime) -> None: await self.async_request_refresh() - async_call_later(self.hass, 2, force_refresh) + return async_call_later(self.hass, 2, force_refresh) def stop_fetch_data( self, module_id: str, data_id: str, all_options: list[str] diff --git a/homeassistant/components/kostal_plenticore/number.py b/homeassistant/components/kostal_plenticore/number.py index 6ea3526e360..885b19faf28 100644 --- a/homeassistant/components/kostal_plenticore/number.py +++ b/homeassistant/components/kostal_plenticore/number.py @@ -188,7 +188,9 @@ class PlenticoreDataNumber( async def async_added_to_hass(self) -> None: """Register this entity on the Update Coordinator.""" await super().async_added_to_hass() - self.coordinator.start_fetch_data(self.module_id, self.data_id) + self.async_on_remove( + self.coordinator.start_fetch_data(self.module_id, self.data_id) + ) async def async_will_remove_from_hass(self) -> None: """Unregister this entity from the Update Coordinator.""" diff --git a/homeassistant/components/kostal_plenticore/select.py b/homeassistant/components/kostal_plenticore/select.py index 6a7c0b35fdf..2118d4b47c6 100644 --- a/homeassistant/components/kostal_plenticore/select.py +++ b/homeassistant/components/kostal_plenticore/select.py @@ -127,7 +127,11 @@ class PlenticoreDataSelect( async def async_added_to_hass(self) -> None: """Register this entity on the Update Coordinator.""" await super().async_added_to_hass() - self.coordinator.start_fetch_data(self.module_id, self.data_id, self.options) + self.async_on_remove( + self.coordinator.start_fetch_data( + self.module_id, self.data_id, self.options + ) + ) async def async_will_remove_from_hass(self) -> None: """Unregister this entity from the Update Coordinator.""" diff --git a/homeassistant/components/kostal_plenticore/sensor.py b/homeassistant/components/kostal_plenticore/sensor.py index a9b9433c1b6..036f2baf98e 100644 --- a/homeassistant/components/kostal_plenticore/sensor.py +++ b/homeassistant/components/kostal_plenticore/sensor.py @@ -769,7 +769,9 @@ class PlenticoreDataSensor( async def async_added_to_hass(self) -> None: """Register this entity on the Update Coordinator.""" await super().async_added_to_hass() - self.coordinator.start_fetch_data(self.module_id, self.data_id) + self.async_on_remove( + self.coordinator.start_fetch_data(self.module_id, self.data_id) + ) async def async_will_remove_from_hass(self) -> None: """Unregister this entity from the Update Coordinator.""" diff --git a/homeassistant/components/kostal_plenticore/switch.py b/homeassistant/components/kostal_plenticore/switch.py index 9dc4740e6e9..4427f4bd4e1 100644 --- a/homeassistant/components/kostal_plenticore/switch.py +++ b/homeassistant/components/kostal_plenticore/switch.py @@ -144,7 +144,9 @@ class PlenticoreDataSwitch( async def async_added_to_hass(self) -> None: """Register this entity on the Update Coordinator.""" await super().async_added_to_hass() - self.coordinator.start_fetch_data(self.module_id, self.data_id) + self.async_on_remove( + self.coordinator.start_fetch_data(self.module_id, self.data_id) + ) async def async_will_remove_from_hass(self) -> None: """Unregister this entity from the Update Coordinator."""