mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix logbook filtering entities (#18721)
* Fix logbook filtering entities * Fix flaky test
This commit is contained in:
parent
1f123ebcc1
commit
9894eff732
@ -391,9 +391,9 @@ def _get_events(hass, config, start_day, end_day, entity_id=None):
|
||||
.filter(Events.event_type.in_(ALL_EVENT_TYPES)) \
|
||||
.filter((Events.time_fired > start_day)
|
||||
& (Events.time_fired < end_day)) \
|
||||
.filter((States.last_updated == States.last_changed)
|
||||
| (States.state_id.is_(None))) \
|
||||
.filter(States.entity_id.in_(entity_ids))
|
||||
.filter(((States.last_updated == States.last_changed) &
|
||||
States.entity_id.in_(entity_ids))
|
||||
| (States.state_id.is_(None)))
|
||||
|
||||
events = execute(query)
|
||||
|
||||
|
@ -62,6 +62,12 @@ class TestComponentLogbook(unittest.TestCase):
|
||||
# Our service call will unblock when the event listeners have been
|
||||
# scheduled. This means that they may not have been processed yet.
|
||||
self.hass.block_till_done()
|
||||
self.hass.data[recorder.DATA_INSTANCE].block_till_done()
|
||||
|
||||
events = list(logbook._get_events(
|
||||
self.hass, {}, dt_util.utcnow() - timedelta(hours=1),
|
||||
dt_util.utcnow() + timedelta(hours=1)))
|
||||
assert len(events) == 2
|
||||
|
||||
assert 1 == len(calls)
|
||||
last_call = calls[-1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user