Avoid calling split_entity_id in event add/remove filters (#118015)

This commit is contained in:
J. Nick Koston 2024-05-23 22:01:33 -10:00 committed by GitHub
parent 01ace8cffd
commit b7a18e9a8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -592,7 +592,10 @@ def _async_domain_added_filter(
"""Filter state changes by entity_id.""" """Filter state changes by entity_id."""
return event_data["old_state"] is None and ( return event_data["old_state"] is None and (
MATCH_ALL in callbacks MATCH_ALL in callbacks
or split_entity_id(event_data["entity_id"])[0] in callbacks or
# If old_state is None, new_state must be set but
# mypy doesn't know that
event_data["new_state"].domain in callbacks # type: ignore[union-attr]
) )
@ -640,7 +643,10 @@ def _async_domain_removed_filter(
"""Filter state changes by entity_id.""" """Filter state changes by entity_id."""
return event_data["new_state"] is None and ( return event_data["new_state"] is None and (
MATCH_ALL in callbacks MATCH_ALL in callbacks
or split_entity_id(event_data["entity_id"])[0] in callbacks or
# If new_state is None, old_state must be set but
# mypy doesn't know that
event_data["old_state"].domain in callbacks # type: ignore[union-attr]
) )