mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00: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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
if CONF_CODE in config:
|
if CONF_CODE in config:
|
||||||
service_data[ATTR_CODE] = config[CONF_CODE]
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "set_hvac_mode":
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "open":
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turn_on":
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "set_humidity":
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "lock":
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
if config[CONF_TYPE] != ATYP_SET_VALUE:
|
|
||||||
return
|
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
const.SERVICE_SET_VALUE,
|
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:
|
async def async_get_action_capabilities(hass: HomeAssistant, config: dict) -> dict:
|
||||||
"""List action capabilities."""
|
"""List action capabilities."""
|
||||||
action_type = config[CONF_TYPE]
|
|
||||||
|
|
||||||
if action_type != ATYP_SET_VALUE:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
fields = {vol.Required(const.ATTR_VALUE): vol.Coerce(float)}
|
fields = {vol.Required(const.ATTR_VALUE): vol.Coerce(float)}
|
||||||
|
|
||||||
return {"extra_fields": vol.Schema(fields)}
|
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
|
hass: HomeAssistant, config: dict, variables: dict, context: Context | None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute a device action."""
|
"""Execute a device action."""
|
||||||
config = ACTION_SCHEMA(config)
|
|
||||||
|
|
||||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turn_on":
|
if config[CONF_TYPE] == "turn_on":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user