Validate generated condition (#27263)
This commit is contained in:
parent
0915d927df
commit
5d1dd6390d
5 changed files with 12 additions and 16 deletions
|
@ -248,7 +248,7 @@ def async_condition_from_config(
|
|||
if CONF_FOR in config:
|
||||
state_config[CONF_FOR] = config[CONF_FOR]
|
||||
|
||||
return condition.state_from_config(state_config, config_validation)
|
||||
return condition.state_from_config(state_config)
|
||||
|
||||
|
||||
async def async_get_condition_capabilities(hass: HomeAssistant, config: dict) -> dict:
|
||||
|
|
|
@ -119,9 +119,7 @@ async def async_call_action_from_config(
|
|||
)
|
||||
|
||||
|
||||
def async_condition_from_config(
|
||||
config: ConfigType, config_validation: bool
|
||||
) -> condition.ConditionCheckerType:
|
||||
def async_condition_from_config(config: ConfigType) -> condition.ConditionCheckerType:
|
||||
"""Evaluate state based on configuration."""
|
||||
condition_type = config[CONF_TYPE]
|
||||
if condition_type == CONF_IS_ON:
|
||||
|
@ -136,7 +134,7 @@ def async_condition_from_config(
|
|||
if CONF_FOR in config:
|
||||
state_config[CONF_FOR] = config[CONF_FOR]
|
||||
|
||||
return condition.state_from_config(state_config, config_validation)
|
||||
return condition.state_from_config(state_config)
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
|
|
|
@ -21,7 +21,7 @@ def async_condition_from_config(
|
|||
"""Evaluate state based on configuration."""
|
||||
if config_validation:
|
||||
config = CONDITION_SCHEMA(config)
|
||||
return toggle_entity.async_condition_from_config(config, config_validation)
|
||||
return toggle_entity.async_condition_from_config(config)
|
||||
|
||||
|
||||
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]:
|
||||
|
|
|
@ -3,14 +3,12 @@ from typing import List
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.components.automation.numeric_state as numeric_state_automation
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONF_ABOVE,
|
||||
CONF_BELOW,
|
||||
CONF_ENTITY_ID,
|
||||
CONF_FOR,
|
||||
CONF_TYPE,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
|
@ -132,12 +130,12 @@ def async_condition_from_config(
|
|||
if config_validation:
|
||||
config = CONDITION_SCHEMA(config)
|
||||
numeric_state_config = {
|
||||
numeric_state_automation.CONF_ENTITY_ID: config[CONF_ENTITY_ID],
|
||||
numeric_state_automation.CONF_ABOVE: config.get(CONF_ABOVE),
|
||||
numeric_state_automation.CONF_BELOW: config.get(CONF_BELOW),
|
||||
numeric_state_automation.CONF_FOR: config.get(CONF_FOR),
|
||||
condition.CONF_CONDITION: "numeric_state",
|
||||
condition.CONF_ENTITY_ID: config[CONF_ENTITY_ID],
|
||||
}
|
||||
if CONF_ABOVE in config:
|
||||
numeric_state_config[condition.CONF_ABOVE] = config[CONF_ABOVE]
|
||||
if CONF_BELOW in config:
|
||||
numeric_state_config[condition.CONF_BELOW] = config[CONF_BELOW]
|
||||
|
||||
return condition.async_numeric_state_from_config(
|
||||
numeric_state_config, config_validation
|
||||
)
|
||||
return condition.async_numeric_state_from_config(numeric_state_config)
|
||||
|
|
|
@ -21,7 +21,7 @@ def async_condition_from_config(
|
|||
"""Evaluate state based on configuration."""
|
||||
if config_validation:
|
||||
config = CONDITION_SCHEMA(config)
|
||||
return toggle_entity.async_condition_from_config(config, config_validation)
|
||||
return toggle_entity.async_condition_from_config(config)
|
||||
|
||||
|
||||
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]:
|
||||
|
|
Loading…
Add table
Reference in a new issue