Fix lingering timer in usb (#91800)

This commit is contained in:
epenet 2023-04-21 13:41:22 +02:00 committed by GitHub
parent 609a7ccda8
commit 9665bc61f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,11 +205,17 @@ class USBDiscovery:
"""Set up USB Discovery."""
await self._async_start_monitor()
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self.async_start)
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.async_stop)
async def async_start(self, event: Event) -> None:
"""Start USB Discovery and run a manual scan."""
await self._async_scan_serial()
async def async_stop(self, event: Event) -> None:
"""Stop USB Discovery."""
if self._request_debouncer:
await self._request_debouncer.async_shutdown()
async def _async_start_monitor(self) -> None:
"""Start monitoring hardware with pyudev."""
if not sys.platform.startswith("linux"):