mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Allow any value when triggering on state attribute (#41261)
This commit is contained in:
@@ -297,7 +297,7 @@ def async_numeric_state_from_config(
|
||||
def state(
|
||||
hass: HomeAssistant,
|
||||
entity: Union[None, str, State],
|
||||
req_state: Union[str, List[str]],
|
||||
req_state: Any,
|
||||
for_period: Optional[timedelta] = None,
|
||||
attribute: Optional[str] = None,
|
||||
) -> bool:
|
||||
@@ -314,17 +314,20 @@ def state(
|
||||
assert isinstance(entity, State)
|
||||
|
||||
if attribute is None:
|
||||
value = entity.state
|
||||
value: Any = entity.state
|
||||
else:
|
||||
value = str(entity.attributes.get(attribute))
|
||||
value = entity.attributes.get(attribute)
|
||||
|
||||
if isinstance(req_state, str):
|
||||
if not isinstance(req_state, list):
|
||||
req_state = [req_state]
|
||||
|
||||
is_state = False
|
||||
for req_state_value in req_state:
|
||||
state_value = req_state_value
|
||||
if INPUT_ENTITY_ID.match(req_state_value) is not None:
|
||||
if (
|
||||
isinstance(req_state_value, str)
|
||||
and INPUT_ENTITY_ID.match(req_state_value) is not None
|
||||
):
|
||||
state_entity = hass.states.get(req_state_value)
|
||||
if not state_entity:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user