diff --git a/homeassistant/components/doorbird/__init__.py b/homeassistant/components/doorbird/__init__.py index 6fc176d4507..1018d23fd8f 100644 --- a/homeassistant/components/doorbird/__init__.py +++ b/homeassistant/components/doorbird/__init__.py @@ -252,8 +252,11 @@ class ConfiguredDoorBird: if self.custom_url is not None: hass_url = self.custom_url - favorites = self.device.favorites() + if not self.doorstation_events: + # User may not have permission to get the favorites + return + favorites = self.device.favorites() for event in self.doorstation_events: self._register_event(hass_url, event, favs=favorites) @@ -272,16 +275,16 @@ class ConfiguredDoorBird: url = f"{hass_url}{API_URL}/{event}?token={self._token}" # Register HA URL as webhook if not already, then get the ID - if not self.webhook_is_registered(url, favs=favs): - self.device.change_favorite("http", f"Home Assistant ({event})", url) + if self.webhook_is_registered(url, favs=favs): + return - if not self.get_webhook_id(url, favs=favs): + self.device.change_favorite("http", f"Home Assistant ({event})", url) + if not self.webhook_is_registered(url): _LOGGER.warning( 'Could not find favorite for URL "%s". ' 'Skipping sensor "%s"', url, event, ) - return def webhook_is_registered(self, url, favs=None) -> bool: """Return whether the given URL is registered as a device favorite."""