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.call_list: List[Dict[str, Any]] = []
self._unsub_dispatcher = None
self.listeners = []
async def setup(self) -> None:
@ -72,7 +73,9 @@ class FreeboxRouter:
# Devices & sensors
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:
"""Update all Freebox platforms."""
@ -147,6 +150,7 @@ class FreeboxRouter:
"""Close the connection."""
if self._api is not None:
await self._api.close()
self._unsub_dispatcher()
self._api = None
@property