mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use entry.async_on_unload in geofency (#144882)
This commit is contained in:
parent
3b1a33d606
commit
fb9be3da79
@ -83,7 +83,6 @@ async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
|
|||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
"beacons": [slugify(beacon) for beacon in mobile_beacons],
|
"beacons": [slugify(beacon) for beacon in mobile_beacons],
|
||||||
"devices": set(),
|
"devices": set(),
|
||||||
"unsub_device_tracker": {},
|
|
||||||
}
|
}
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -153,7 +152,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
webhook.async_unregister(hass, entry.data[CONF_WEBHOOK_ID])
|
webhook.async_unregister(hass, entry.data[CONF_WEBHOOK_ID])
|
||||||
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
|
|
||||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async_add_entities([GeofencyEntity(device, gps, location_name, attributes)])
|
async_add_entities([GeofencyEntity(device, gps, location_name, attributes)])
|
||||||
|
|
||||||
hass.data[DOMAIN]["unsub_device_tracker"][config_entry.entry_id] = (
|
config_entry.async_on_unload(
|
||||||
async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user