mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Fix webhook when doorbird not yet setup (#42657)
This commit is contained in:
parent
34f5ad33e9
commit
cca661574d
@ -11,9 +11,32 @@ def get_mac_address_from_doorstation_info(doorstation_info):
|
|||||||
|
|
||||||
|
|
||||||
def get_doorstation_by_token(hass, token):
|
def get_doorstation_by_token(hass, token):
|
||||||
"""Get doorstation by slug."""
|
"""Get doorstation by token."""
|
||||||
for config_entry_id in hass.data[DOMAIN]:
|
return _get_doorstation_by_attr(hass, "token", token)
|
||||||
doorstation = hass.data[DOMAIN][config_entry_id][DOOR_STATION]
|
|
||||||
|
|
||||||
if token == doorstation.token:
|
|
||||||
|
def get_doorstation_by_slug(hass, slug):
|
||||||
|
"""Get doorstation by slug."""
|
||||||
|
return _get_doorstation_by_attr(hass, "slug", slug)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_doorstation_by_attr(hass, attr, val):
|
||||||
|
for entry in hass.data[DOMAIN].values():
|
||||||
|
if DOOR_STATION not in entry:
|
||||||
|
continue
|
||||||
|
|
||||||
|
doorstation = entry[DOOR_STATION]
|
||||||
|
|
||||||
|
if getattr(doorstation, attr) == val:
|
||||||
return doorstation
|
return doorstation
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_all_doorstations(hass):
|
||||||
|
"""Get all doorstations."""
|
||||||
|
return [
|
||||||
|
entry[DOOR_STATION]
|
||||||
|
for entry in hass.data[DOMAIN].values()
|
||||||
|
if DOOR_STATION in entry
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user