Adjust entity filters to make includes stronger than excludes (#74080)

* Adjust entity filters to make includes stronger than excludes

Fixes #59080

* adjust test for stronger entity glob includes

* sync with docs
This commit is contained in:
J. Nick Koston 2022-06-28 11:42:51 -05:00 committed by GitHub
parent 040ece76ab
commit a8349a4866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 312 additions and 87 deletions

View file

@ -753,7 +753,7 @@ async def test_fetch_period_api_with_entity_glob_include_and_exclude(
{
"history": {
"exclude": {
"entity_globs": ["light.many*"],
"entity_globs": ["light.many*", "binary_sensor.*"],
},
"include": {
"entity_globs": ["light.m*"],
@ -769,6 +769,7 @@ async def test_fetch_period_api_with_entity_glob_include_and_exclude(
hass.states.async_set("light.many_state_changes", "on")
hass.states.async_set("switch.match", "on")
hass.states.async_set("media_player.test", "on")
hass.states.async_set("binary_sensor.exclude", "on")
await async_wait_recording_done(hass)
@ -778,10 +779,11 @@ async def test_fetch_period_api_with_entity_glob_include_and_exclude(
)
assert response.status == HTTPStatus.OK
response_json = await response.json()
assert len(response_json) == 3
assert response_json[0][0]["entity_id"] == "light.match"
assert response_json[1][0]["entity_id"] == "media_player.test"
assert response_json[2][0]["entity_id"] == "switch.match"
assert len(response_json) == 4
assert response_json[0][0]["entity_id"] == "light.many_state_changes"
assert response_json[1][0]["entity_id"] == "light.match"
assert response_json[2][0]["entity_id"] == "media_player.test"
assert response_json[3][0]["entity_id"] == "switch.match"
async def test_entity_ids_limit_via_api(hass, hass_client, recorder_mock):