Fix doorbird with externally added events (#123313)

This commit is contained in:
J. Nick Koston 2024-08-08 01:56:40 -05:00 committed by GitHub
parent 2144a9a7b2
commit 135c80186f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -195,7 +195,7 @@ class ConfiguredDoorBird:
title: str | None = data.get("title")
if not title or not title.startswith("Home Assistant"):
continue
event = title.split("(")[1].strip(")")
event = title.partition("(")[2].strip(")")
if input_type := favorite_input_type.get(identifier):
events.append(DoorbirdEvent(event, input_type))
elif input_type := default_event_types.get(event):

View File

@ -7,6 +7,10 @@
"1": {
"title": "Home Assistant (mydoorbird_motion)",
"value": "http://127.0.0.1:8123/api/doorbird/mydoorbird_motion?token=01J2F4B97Y7P1SARXEJ6W07EKD"
},
"2": {
"title": "externally added event",
"value": "http://127.0.0.1/"
}
}
}

View File

@ -49,4 +49,4 @@ async def test_reset_favorites_button(
DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: reset_entity_id}, blocking=True
)
assert hass.states.get(reset_entity_id).state != STATE_UNKNOWN
assert doorbird_entry.api.delete_favorite.call_count == 2
assert doorbird_entry.api.delete_favorite.call_count == 3