Fix device_ids being filtered when entities also specified in the logbook (#72122)

This commit is contained in:
J. Nick Koston 2022-05-18 23:27:31 -05:00 committed by GitHub
parent a6402697bb
commit 272e65f56d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -59,7 +59,6 @@ from homeassistant.helpers.entityfilter import (
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
EntityFilter,
convert_include_exclude_filter,
generate_filter,
)
from homeassistant.helpers.integration_platform import (
async_process_integration_platforms,
@ -579,8 +578,8 @@ def _get_events(
] = hass.data.get(DOMAIN, {})
format_time = _row_time_fired_timestamp if timestamp else _row_time_fired_isoformat
entity_name_cache = EntityNameCache(hass)
if entity_ids is not None:
entities_filter = generate_filter([], entity_ids, [], [])
if entity_ids or device_ids:
entities_filter = None
def yield_rows(query: Query) -> Generator[Row, None, None]:
"""Yield rows from the database."""

View file

@ -2546,10 +2546,13 @@ async def test_get_events_with_device_ids(hass, hass_ws_client, recorder_mock):
assert response["id"] == 2
results = response["result"]
assert results[0]["entity_id"] == "light.kitchen"
assert results[0]["state"] == "on"
assert results[0]["domain"] == "test"
assert results[0]["message"] == "is on fire"
assert results[0]["name"] == "device name"
assert results[1]["entity_id"] == "light.kitchen"
assert results[1]["state"] == "off"
assert results[1]["state"] == "on"
assert results[2]["entity_id"] == "light.kitchen"
assert results[2]["state"] == "off"
await client.send_json(
{