From f1268ad1b7819a90da7b4da602de42e09409568c Mon Sep 17 00:00:00 2001 From: Tomaae Date: Mon, 24 Jan 2022 13:45:42 +0100 Subject: [PATCH] Fixed listeners unload after integration is removed --- .../mikrotik_router/mikrotik_controller.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 9b74e1c..e9289f6 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -167,22 +167,24 @@ def __init__(self, hass, config_entry): self.major_fw_version = 0 - self._force_update_callback = None - self._force_fwupdate_check_callback = None - self._async_ping_tracked_hosts_callback = None - self.async_mac_lookup = AsyncMacLookup() # self.async_mac_lookup.update_vendors() async def async_init(self): - self._force_update_callback = async_track_time_interval( - self.hass, self.force_update, self.option_scan_interval + self.listeners.append( + async_track_time_interval( + self.hass, self.force_update, self.option_scan_interval + ) ) - self._force_fwupdate_check_callback = async_track_time_interval( - self.hass, self.force_fwupdate_check, timedelta(hours=1) + self.listeners.append( + async_track_time_interval( + self.hass, self.force_fwupdate_check, timedelta(hours=1) + ) ) - self._async_ping_tracked_hosts_callback = async_track_time_interval( - self.hass, self.async_ping_tracked_hosts, timedelta(seconds=15) + self.listeners.append( + async_track_time_interval( + self.hass, self.async_ping_tracked_hosts, timedelta(seconds=15) + ) ) # ---------------------------