mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Cancel callbacks on Withings entry unload (#101536)
This commit is contained in:
parent
6c2d1e2142
commit
7369ae8c9f
@ -161,7 +161,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
webhook_name = "Withings"
|
webhook_name = "Withings"
|
||||||
if entry.title != DEFAULT_TITLE:
|
if entry.title != DEFAULT_TITLE:
|
||||||
webhook_name = " ".join([DEFAULT_TITLE, entry.title])
|
webhook_name = f"{DEFAULT_TITLE} {entry.title}"
|
||||||
|
|
||||||
webhook_register(
|
webhook_register(
|
||||||
hass,
|
hass,
|
||||||
@ -183,14 +183,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
if state is cloud.CloudConnectionState.CLOUD_DISCONNECTED:
|
if state is cloud.CloudConnectionState.CLOUD_DISCONNECTED:
|
||||||
await unregister_webhook(None)
|
await unregister_webhook(None)
|
||||||
async_call_later(hass, 30, register_webhook)
|
entry.async_on_unload(async_call_later(hass, 30, register_webhook))
|
||||||
|
|
||||||
if cloud.async_active_subscription(hass):
|
if cloud.async_active_subscription(hass):
|
||||||
if cloud.async_is_connected(hass):
|
if cloud.async_is_connected(hass):
|
||||||
await register_webhook(None)
|
await register_webhook(None)
|
||||||
cloud.async_listen_connection_change(hass, manage_cloudhook)
|
entry.async_on_unload(
|
||||||
|
cloud.async_listen_connection_change(hass, manage_cloudhook)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
async_at_started(hass, register_webhook)
|
entry.async_on_unload(async_at_started(hass, register_webhook))
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user