Reolink unsubscribe webhook when first refresh fails (#87147)

* catch ValueError on webhook async_register

* add ONVIF to webhook_id

* Unsubscribe webhook when ConfigEntryNotReady for async_config_entry_first_refresh

* Revert catching ValueError
This commit is contained in:
starkillerOG 2023-02-02 21:21:41 +01:00 committed by GitHub
parent f9d7d65f3a
commit f439a94a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -80,7 +80,11 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
update_interval=timedelta(seconds=DEVICE_UPDATE_INTERVAL),
)
# Fetch initial data so we have data when entities subscribe
await coordinator_device_config_update.async_config_entry_first_refresh()
try:
await coordinator_device_config_update.async_config_entry_first_refresh()
except ConfigEntryNotReady as err:
await host.stop()
raise err
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = ReolinkData(
host=host,

View File

@ -250,7 +250,7 @@ class ReolinkHost:
async def register_webhook(self) -> None:
"""Register the webhook for motion events."""
self.webhook_id = f"{DOMAIN}_{self.unique_id.replace(':', '')}"
self.webhook_id = f"{DOMAIN}_{self.unique_id.replace(':', '')}_ONVIF"
event_id = self.webhook_id
webhook.async_register(