Add is_state_attr method.
Returns True if the entity exists and has an attribute with the given name and value.
This commit is contained in:
parent
326e26fbeb
commit
11f32d0500
4 changed files with 29 additions and 1 deletions
|
@ -468,6 +468,13 @@ class StateMachine(object):
|
|||
return (entity_id in self._states and
|
||||
self._states[entity_id].state == state)
|
||||
|
||||
def is_state_attr(self, entity_id, name, value):
|
||||
"""Test if entity exists and has a state attribute set to value."""
|
||||
entity_id = entity_id.lower()
|
||||
|
||||
return (entity_id in self._states and
|
||||
self._states[entity_id].attributes.get(name, None) == value)
|
||||
|
||||
def remove(self, entity_id):
|
||||
"""Remove the state of an entity.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue