Skip to content

Instantly share code, notes, and snippets.

@dankarization
Last active December 28, 2024 17:26
Select multiple entities to link their on/off state. If any selected entity is turned on or off, the other selected entities will be sent a matching on or off command.
@sheharyarn
Copy link

Instead of this:

- condition: template
  value_template: '{{ trigger.from_state.state != "unavailable" }}'
- condition: template
  value_template: '{{ trigger.from_state.state != "unknown" }}'

wouldn't it be better to do this?

- condition: template
  value_template: '{{ (trigger.from_state.state == "on") or (trigger.from_state.state == "off") }}'

There might be more states (other than unavailable/unknown) in the future that could cause errors, so instead of checking against all possible negatives, we should only validate allowed states/attributes?

@shageman
Copy link

This blueprint works great. It creates a great deal of log errors because to_state and from_state can't always be found. So, I am checking for their availability in my fork: https://gist.github.com/shageman/dbc21d5d50095053c6d0616076a0d76b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment