Support 'stop' action for covers in device automation (#38219)
This commit is contained in:
parent
d02c432e4d
commit
c795c68bc0
4 changed files with 52 additions and 6 deletions
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
SERVICE_OPEN_COVER_TILT,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
SERVICE_SET_COVER_TILT_POSITION,
|
||||
SERVICE_STOP_COVER,
|
||||
)
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.helpers import entity_registry
|
||||
|
@ -31,9 +32,10 @@ from . import (
|
|||
SUPPORT_OPEN_TILT,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_SET_TILT_POSITION,
|
||||
SUPPORT_STOP,
|
||||
)
|
||||
|
||||
CMD_ACTION_TYPES = {"open", "close", "open_tilt", "close_tilt"}
|
||||
CMD_ACTION_TYPES = {"open", "close", "stop", "open_tilt", "close_tilt"}
|
||||
POSITION_ACTION_TYPES = {"set_position", "set_tilt_position"}
|
||||
|
||||
CMD_ACTION_SCHEMA = cv.DEVICE_ACTION_BASE_SCHEMA.extend(
|
||||
|
@ -99,6 +101,15 @@ async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
|
|||
CONF_TYPE: "close",
|
||||
}
|
||||
)
|
||||
if supported_features & SUPPORT_STOP:
|
||||
actions.append(
|
||||
{
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_ENTITY_ID: entry.entity_id,
|
||||
CONF_TYPE: "stop",
|
||||
}
|
||||
)
|
||||
|
||||
if supported_features & SUPPORT_SET_TILT_POSITION:
|
||||
actions.append(
|
||||
|
@ -160,6 +171,8 @@ async def async_call_action_from_config(
|
|||
service = SERVICE_OPEN_COVER
|
||||
elif config[CONF_TYPE] == "close":
|
||||
service = SERVICE_CLOSE_COVER
|
||||
elif config[CONF_TYPE] == "stop":
|
||||
service = SERVICE_STOP_COVER
|
||||
elif config[CONF_TYPE] == "open_tilt":
|
||||
service = SERVICE_OPEN_COVER_TILT
|
||||
elif config[CONF_TYPE] == "close_tilt":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue