It is often useful to set the state of one entity based on another. Maybe one light should be turned on when another light is on. Or a template helper computes the desired state of a switch.
Unlike the example in the blueprint tutorial, the Boolean Follower only requires its input to have a state which can be ‘on’ or ‘off’, and the entity which is supposed to match that state must have a ‘turn_on’ or ‘turn_off’ service.
If the input state is other than on or off, the automation will fail, which I think is the desired behavior.
blueprint:
name: Boolean Follower
description: An entity with turn_on and turn_off follows the state of another entity with on or off states.
domain: automation
input:
to_follow:
name: Entity to Follow State
description: The entity with the desired state.
selector:
entity:
target_entity:
name: followed
description: The entity that should bept in sync with the entity to Follow State
selector:
entity:
mode: restart
triggers:
- trigger: state
entity_id: !input to_follow
actions:
- action: homeassistant.turn_{{ states(trigger.entity_id) }}
metadata: {}
data: {}
target:
entity_id: !input target_entity