Fix Freebox unsub dispatcher (#38842)

This commit is contained in:
Quentame 2020-08-14 03:56:06 +02:00 committed by GitHub
parent fceba0bb88
commit f26a49eca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,7 @@ class FreeboxRouter:
self.sensors_connection: Dict[str, float] = {} self.sensors_connection: Dict[str, float] = {}
self.call_list: List[Dict[str, Any]] = [] self.call_list: List[Dict[str, Any]] = []
self._unsub_dispatcher = None
self.listeners = [] self.listeners = []
async def setup(self) -> None: async def setup(self) -> None:
@ -72,7 +73,9 @@ class FreeboxRouter:
# Devices & sensors # Devices & sensors
await self.update_all() await self.update_all()
async_track_time_interval(self.hass, self.update_all, SCAN_INTERVAL) self._unsub_dispatcher = async_track_time_interval(
self.hass, self.update_all, SCAN_INTERVAL
)
async def update_all(self, now: Optional[datetime] = None) -> None: async def update_all(self, now: Optional[datetime] = None) -> None:
"""Update all Freebox platforms.""" """Update all Freebox platforms."""
@ -147,6 +150,7 @@ class FreeboxRouter:
"""Close the connection.""" """Close the connection."""
if self._api is not None: if self._api is not None:
await self._api.close() await self._api.close()
self._unsub_dispatcher()
self._api = None self._api = None
@property @property