mirror of
https://github.com/home-assistant/core
synced 2024-08-02 23:40:32 +02:00
Validate device action schemas once (#48351)
This commit is contained in:
parent
5b17aaf9d5
commit
4fbc3da196
@ -112,8 +112,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
if CONF_CODE in config:
|
||||
service_data[ATTR_CODE] = config[CONF_CODE]
|
||||
|
@ -79,8 +79,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "set_hvac_mode":
|
||||
|
@ -165,8 +165,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "open":
|
||||
|
@ -62,8 +62,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "turn_on":
|
||||
|
@ -82,8 +82,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "set_humidity":
|
||||
|
@ -78,8 +78,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "lock":
|
||||
|
@ -55,11 +55,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
if config[CONF_TYPE] != ATYP_SET_VALUE:
|
||||
return
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
const.SERVICE_SET_VALUE,
|
||||
@ -74,11 +69,6 @@ async def async_call_action_from_config(
|
||||
|
||||
async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict:
|
||||
"""List action capabilities."""
|
||||
action_type = config[CONF_TYPE]
|
||||
|
||||
if action_type != ATYP_SET_VALUE:
|
||||
return {}
|
||||
|
||||
fields = {vol.Required(const.ATTR_VALUE): vol.Coerce(float)}
|
||||
|
||||
return {"extra_fields": vol.Schema(fields)}
|
||||
|
@ -61,8 +61,6 @@ async def async_call_action_from_config(
|
||||
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
config = ACTION_SCHEMA(config)
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "turn_on":
|
||||
|
Loading…
Reference in New Issue
Block a user