From ea44b534e6bd51287ca4189a22dff7924af6746f Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Thu, 30 May 2024 19:14:54 +0200 Subject: [PATCH] Fix group platform dependencies (#118499) --- homeassistant/components/group/manifest.json | 9 ++++ tests/components/group/test_init.py | 55 +++++++++++++++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/group/manifest.json b/homeassistant/components/group/manifest.json index 7ead19414af..d86fc4ba622 100644 --- a/homeassistant/components/group/manifest.json +++ b/homeassistant/components/group/manifest.json @@ -1,6 +1,15 @@ { "domain": "group", "name": "Group", + "after_dependencies": [ + "alarm_control_panel", + "climate", + "device_tracker", + "person", + "plant", + "vacuum", + "water_heater" + ], "codeowners": ["@home-assistant/core"], "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/group", diff --git a/tests/components/group/test_init.py b/tests/components/group/test_init.py index 4f928e0a8c2..e2e618002ac 100644 --- a/tests/components/group/test_init.py +++ b/tests/components/group/test_init.py @@ -1487,28 +1487,67 @@ async def test_group_vacuum_on(hass: HomeAssistant) -> None: assert hass.states.get("group.group_zero").state == STATE_ON -async def test_device_tracker_not_home(hass: HomeAssistant) -> None: +@pytest.mark.parametrize( + ("entity_state_list", "group_state"), + [ + ( + { + "device_tracker.one": "not_home", + "device_tracker.two": "not_home", + "device_tracker.three": "not_home", + }, + "not_home", + ), + ( + { + "device_tracker.one": "home", + "device_tracker.two": "not_home", + "device_tracker.three": "not_home", + }, + "home", + ), + ( + { + "device_tracker.one": "home", + "device_tracker.two": "elsewhere", + "device_tracker.three": "not_home", + }, + "home", + ), + ( + { + "device_tracker.one": "not_home", + "device_tracker.two": "elsewhere", + "device_tracker.three": "not_home", + }, + "not_home", + ), + ], +) +async def test_device_tracker_or_person_not_home( + hass: HomeAssistant, + entity_state_list: dict[str, str], + group_state: str, +) -> None: """Test group of device_tracker not_home.""" await async_setup_component(hass, "device_tracker", {}) + await async_setup_component(hass, "person", {}) await hass.async_block_till_done() - hass.states.async_set("device_tracker.one", "not_home") - hass.states.async_set("device_tracker.two", "not_home") - hass.states.async_set("device_tracker.three", "not_home") + for entity_id, state in entity_state_list.items(): + hass.states.async_set(entity_id, state) assert await async_setup_component( hass, "group", { "group": { - "group_zero": { - "entities": "device_tracker.one, device_tracker.two, device_tracker.three" - }, + "group_zero": {"entities": ", ".join(entity_state_list)}, } }, ) await hass.async_block_till_done() - assert hass.states.get("group.group_zero").state == "not_home" + assert hass.states.get("group.group_zero").state == group_state async def test_light_removed(hass: HomeAssistant) -> None: