From bc22e79c7b034df3d1779038f67042ba1a053b1f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 4 Jun 2022 15:43:23 -1000 Subject: [PATCH] Add a test for a complex entity filter (#73005) --- tests/helpers/test_entityfilter.py | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/helpers/test_entityfilter.py b/tests/helpers/test_entityfilter.py index 9576c7d95b6..043fb44a95a 100644 --- a/tests/helpers/test_entityfilter.py +++ b/tests/helpers/test_entityfilter.py @@ -303,3 +303,66 @@ def test_exlictly_included(): assert not filt.explicitly_excluded("switch.other") assert filt.explicitly_excluded("sensor.weather_5") assert filt.explicitly_excluded("light.kitchen") + + +def test_complex_include_exclude_filter(): + """Test a complex include exclude filter.""" + conf = { + "include": { + "domains": ["switch", "person"], + "entities": ["group.family"], + "entity_globs": [ + "sensor.*_sensor_temperature", + "sensor.*_actueel", + "sensor.*_totaal", + "sensor.calculated*", + "sensor.solaredge_*", + "sensor.speedtest*", + "sensor.teller*", + "sensor.zp*", + "binary_sensor.*_sensor_motion", + "binary_sensor.*_door", + "sensor.water_*ly", + "sensor.gas_*ly", + ], + }, + "exclude": { + "domains": [ + "alarm_control_panel", + "alert", + "automation", + "button", + "camera", + "climate", + "counter", + "cover", + "geo_location", + "group", + "input_boolean", + "input_datetime", + "input_number", + "input_select", + "input_text", + "light", + "media_player", + "number", + "proximity", + "remote", + "scene", + "script", + "sun", + "timer", + "updater", + "variable", + "weather", + "zone", + ], + "entities": [ + "sensor.solaredge_last_updatetime", + "sensor.solaredge_last_changed", + ], + "entity_globs": ["switch.*_light_level", "switch.sonos_*"], + }, + } + filt: EntityFilter = INCLUDE_EXCLUDE_FILTER_SCHEMA(conf) + assert filt("switch.espresso_keuken") is True