Make async_track_state_change/report_event listeners fire in order (#148766)

This commit is contained in:
Erik Montnemery 2025-07-21 13:07:52 +02:00 committed by GitHub
parent 1fba61973d
commit 67c68dedba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -402,7 +402,7 @@ def _async_track_state_change_event(
_KEYED_TRACK_STATE_REPORT = _KeyedEventTracker( _KEYED_TRACK_STATE_REPORT = _KeyedEventTracker(
key=_TRACK_STATE_REPORT_DATA, key=_TRACK_STATE_REPORT_DATA,
event_type=EVENT_STATE_REPORTED, event_type=EVENT_STATE_REPORTED,
dispatcher_callable=_async_dispatch_entity_id_event, dispatcher_callable=_async_dispatch_entity_id_event_soon,
filter_callable=_async_state_filter, filter_callable=_async_state_filter,
) )

View File

@ -4969,11 +4969,9 @@ async def test_async_track_state_report_change_event(hass: HomeAssistant) -> Non
hass.states.async_set(entity_id, state) hass.states.async_set(entity_id, state)
await hass.async_block_till_done() await hass.async_block_till_done()
# The out-of-order is a result of state change listeners scheduled with
# loop.call_soon, whereas state report listeners are called immediately.
assert tracker_called == { assert tracker_called == {
"light.bowl": ["on", "off", "on", "off"], "light.bowl": ["on", "on", "off", "off"],
"light.top": ["on", "off", "on", "off"], "light.top": ["on", "on", "off", "off"],
} }