mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Support open next and close next actions for shades (#125097)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
bcbba04f27
commit
50025971d8
@ -237,6 +237,20 @@ BUTTONS: tuple[BondButtonEntityDescription, ...] = (
|
|||||||
mutually_exclusive=Action.SET_POSITION,
|
mutually_exclusive=Action.SET_POSITION,
|
||||||
argument=STEP_SIZE,
|
argument=STEP_SIZE,
|
||||||
),
|
),
|
||||||
|
BondButtonEntityDescription(
|
||||||
|
key=Action.OPEN_NEXT,
|
||||||
|
name="Open Next",
|
||||||
|
translation_key="open_next",
|
||||||
|
mutually_exclusive=None,
|
||||||
|
argument=None,
|
||||||
|
),
|
||||||
|
BondButtonEntityDescription(
|
||||||
|
key=Action.CLOSE_NEXT,
|
||||||
|
name="Close Next",
|
||||||
|
translation_key="close_next",
|
||||||
|
mutually_exclusive=None,
|
||||||
|
argument=None,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +84,12 @@
|
|||||||
},
|
},
|
||||||
"decrease_position": {
|
"decrease_position": {
|
||||||
"default": "mdi:minus-box"
|
"default": "mdi:minus-box"
|
||||||
|
},
|
||||||
|
"open_next": {
|
||||||
|
"default": "mdi:plus-box"
|
||||||
|
},
|
||||||
|
"close_next": {
|
||||||
|
"default": "mdi:minus-box"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"light": {
|
"light": {
|
||||||
|
@ -57,6 +57,15 @@ def light(name: str):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def motorized_shade(name: str):
|
||||||
|
"""Create a motorized shade with a given name."""
|
||||||
|
return {
|
||||||
|
"name": name,
|
||||||
|
"type": DeviceType.MOTORIZED_SHADES,
|
||||||
|
"actions": [Action.OPEN, Action.OPEN_NEXT, Action.CLOSE, Action.CLOSE_NEXT],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(
|
async def test_entity_registry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
@ -180,3 +189,38 @@ async def test_press_button(hass: HomeAssistant) -> None:
|
|||||||
mock_action.assert_called_once_with(
|
mock_action.assert_called_once_with(
|
||||||
"test-device-id", Action(Action.START_DECREASING_BRIGHTNESS)
|
"test-device-id", Action(Action.START_DECREASING_BRIGHTNESS)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_motorized_shade_actions(hass: HomeAssistant) -> None:
|
||||||
|
"""Tests motorized shade open next and close next actions."""
|
||||||
|
await setup_platform(
|
||||||
|
hass,
|
||||||
|
BUTTON_DOMAIN,
|
||||||
|
motorized_shade("name-1"),
|
||||||
|
bond_device_id="test-device-id",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert hass.states.get("button.name_1_open_next")
|
||||||
|
assert hass.states.get("button.name_1_close_next")
|
||||||
|
|
||||||
|
with patch_bond_action() as mock_action, patch_bond_device_state():
|
||||||
|
await hass.services.async_call(
|
||||||
|
BUTTON_DOMAIN,
|
||||||
|
SERVICE_PRESS,
|
||||||
|
{ATTR_ENTITY_ID: "button.name_1_open_next"},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
mock_action.assert_called_once_with("test-device-id", Action(Action.OPEN_NEXT))
|
||||||
|
|
||||||
|
with patch_bond_action() as mock_action, patch_bond_device_state():
|
||||||
|
await hass.services.async_call(
|
||||||
|
BUTTON_DOMAIN,
|
||||||
|
SERVICE_PRESS,
|
||||||
|
{ATTR_ENTITY_ID: "button.name_1_close_next"},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
mock_action.assert_called_once_with("test-device-id", Action(Action.CLOSE_NEXT))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user