Skip to content

Commit

Permalink
fix: If the scene 'on' state includes entities that are off don't che…
Browse files Browse the repository at this point in the history
…ck additional attributes (#168)
  • Loading branch information
cayossarian authored Dec 29, 2024
1 parent 3aa5776 commit 1c50f98
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/stateful_scenes/StatefulScenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def is_interesting_update(self, old_state, new_state):
return False

def check_state(self, entity_id, new_state):
"""Check the state of the scene."""
"""Check if entity's current state matches the scene's defined state."""
if new_state is None:
_LOGGER.warning(f"Entity not found: {entity_id}")
return False
Expand All @@ -273,6 +273,11 @@ def check_state(self, entity_id, new_state):
return False

# Check attributes
# If both desired and current states are "off", consider it a match regardless of attributes
if new_state.state == "off" and self.entities[entity_id]["state"] == "off":
return True

# Only check attributes if entity isn't "off"
if new_state.domain in ATTRIBUTES_TO_CHECK:
entity_attrs = new_state.attributes
for attribute in ATTRIBUTES_TO_CHECK.get(new_state.domain):
Expand Down

0 comments on commit 1c50f98

Please sign in to comment.