From ee3cebe37b5d74546cc83fdb31ff07351adaeabb Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Tue, 25 Apr 2023 22:19:37 +0200 Subject: [PATCH] Enable open,close,stop device actions for all covers (#92006) --- .../components/cover/device_action.py | 22 +++++++++---------- tests/components/cover/test_device_action.py | 14 ++++++++---- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/cover/device_action.py b/homeassistant/components/cover/device_action.py index 9b2bb05bb0f..dd22821d5e4 100644 --- a/homeassistant/components/cover/device_action.py +++ b/homeassistant/components/cover/device_action.py @@ -82,21 +82,19 @@ async def async_get_actions( if supported_features & SUPPORT_SET_POSITION: actions.append({**base_action, CONF_TYPE: "set_position"}) - else: - if supported_features & SUPPORT_OPEN: - actions.append({**base_action, CONF_TYPE: "open"}) - if supported_features & SUPPORT_CLOSE: - actions.append({**base_action, CONF_TYPE: "close"}) - if supported_features & SUPPORT_STOP: - actions.append({**base_action, CONF_TYPE: "stop"}) + if supported_features & SUPPORT_OPEN: + actions.append({**base_action, CONF_TYPE: "open"}) + if supported_features & SUPPORT_CLOSE: + actions.append({**base_action, CONF_TYPE: "close"}) + if supported_features & SUPPORT_STOP: + actions.append({**base_action, CONF_TYPE: "stop"}) if supported_features & SUPPORT_SET_TILT_POSITION: actions.append({**base_action, CONF_TYPE: "set_tilt_position"}) - else: - if supported_features & SUPPORT_OPEN_TILT: - actions.append({**base_action, CONF_TYPE: "open_tilt"}) - if supported_features & SUPPORT_CLOSE_TILT: - actions.append({**base_action, CONF_TYPE: "close_tilt"}) + if supported_features & SUPPORT_OPEN_TILT: + actions.append({**base_action, CONF_TYPE: "open_tilt"}) + if supported_features & SUPPORT_CLOSE_TILT: + actions.append({**base_action, CONF_TYPE: "close_tilt"}) return actions diff --git a/tests/components/cover/test_device_action.py b/tests/components/cover/test_device_action.py index 84f8c24792b..354e840e548 100644 --- a/tests/components/cover/test_device_action.py +++ b/tests/components/cover/test_device_action.py @@ -224,9 +224,9 @@ async def test_get_action_capabilities_set_pos( actions = await async_get_device_automations( hass, DeviceAutomationType.ACTION, device_entry.id ) - assert len(actions) == 1 # set_position + assert len(actions) == 4 # set_position, open, close, stop action_types = {action["type"] for action in actions} - assert action_types == {"set_position"} + assert action_types == {"set_position", "open", "close", "stop"} for action in actions: capabilities = await async_get_device_automation_capabilities( hass, DeviceAutomationType.ACTION, action @@ -275,9 +275,15 @@ async def test_get_action_capabilities_set_tilt_pos( actions = await async_get_device_automations( hass, DeviceAutomationType.ACTION, device_entry.id ) - assert len(actions) == 3 + assert len(actions) == 5 action_types = {action["type"] for action in actions} - assert action_types == {"open", "close", "set_tilt_position"} + assert action_types == { + "open", + "close", + "set_tilt_position", + "open_tilt", + "close_tilt", + } for action in actions: capabilities = await async_get_device_automation_capabilities( hass, DeviceAutomationType.ACTION, action