8000 Prevent doorbird integration from overloading the device on startup by bdraco · Pull Request #63253 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent doorbird integration from overloading the device on startup #63253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions homeassistant/components/doorbird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ def register_events(self, hass):
if self.custom_url is not None:
hass_url = self.custom_url

favorites = self.device.favorites()

for event in self.doorstation_events:
self._register_event(hass_url, event)
self._register_event(hass_url, event, favs=favorites)

_LOGGER.info("Successfully registered URL for %s on %s", event, self.name)

Expand All @@ -261,15 +263,15 @@ def slug(self):
def _get_event_name(self, event):
return f"{self.slug}_{event}"

def _register_event(self, hass_url, event):
def _register_event(self, hass_url, event, favs=None):
"""Add a schedule entry in the device for a sensor."""
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):
if not self.webhook_is_registered(url, favs=favs):
self.device.change_favorite("http", f"Home Assistant ({event})", url)

if not self.get_webhook_id(url):
if not self.get_webhook_id(url, favs=favs):
_LOGGER.warning(
'Could not find favorite for URL "%s". ' 'Skipping sensor "%s"',
url,
Expand Down
0