mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
fjaraskupan: Make sure we stop bleak on home assistant stop (#74545)
* Make sure we stop bleak on home assistant stop * Fix typing Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
c303d6e717
commit
104d236646
@ -12,8 +12,8 @@ from bleak.backends.scanner import AdvertisementData
|
|||||||
from fjaraskupan import Device, State, device_filter
|
from fjaraskupan import Device, State, device_filter
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import (
|
from homeassistant.helpers.dispatcher import (
|
||||||
async_dispatcher_connect,
|
async_dispatcher_connect,
|
||||||
async_dispatcher_send,
|
async_dispatcher_send,
|
||||||
@ -131,6 +131,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
scanner.register_detection_callback(detection_callback)
|
scanner.register_detection_callback(detection_callback)
|
||||||
await scanner.start()
|
await scanner.start()
|
||||||
|
|
||||||
|
async def on_hass_stop(event: Event) -> None:
|
||||||
|
await scanner.stop()
|
||||||
|
|
||||||
|
entry.async_on_unload(
|
||||||
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
|
||||||
|
)
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user