Enable open,close,stop device actions for all covers (#92006)

pull/92031/head
Michel van de Wetering 2023-04-25 22:19:37 +02:00 committed by GitHub
parent 18f7b92438
commit ee3cebe37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 16 deletions

View File

@ -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

View File

@ -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