mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use entry.async_on_unload in gpslogger (#144883)
This commit is contained in:
parent
993e98a43f
commit
a9238c7577
@ -90,7 +90,7 @@ async def handle_webhook(
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Configure based on config entry."""
|
"""Configure based on config entry."""
|
||||||
hass.data.setdefault(DOMAIN, {"devices": set(), "unsub_device_tracker": {}})
|
hass.data.setdefault(DOMAIN, {"devices": set()})
|
||||||
webhook.async_register(
|
webhook.async_register(
|
||||||
hass, DOMAIN, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
hass, DOMAIN, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
||||||
)
|
)
|
||||||
@ -103,7 +103,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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,9 +42,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async_add_entities([GPSLoggerEntity(device, gps, battery, accuracy, attrs)])
|
async_add_entities([GPSLoggerEntity(device, gps, battery, accuracy, attrs)])
|
||||||
|
|
||||||
hass.data[DOMAIN]["unsub_device_tracker"][entry.entry_id] = (
|
entry.async_on_unload(async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data))
|
||||||
async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Restore previously loaded devices
|
# Restore previously loaded devices
|
||||||
dev_reg = dr.async_get(hass)
|
dev_reg = dr.async_get(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user