Boolean State Follower

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.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

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

As an example of a way I use this, I have a complicated set of circumstances in which I want my holiday lights on.

If it is dark out any any of this are true:

  • time between 6AM and 10:30PM
  • person detected by frigate
  • someone is arriving home

or my outdoor light switch for another set of lights is on (mainly to force the lights on during day for testing).

I compute that with a template helper, and turn on a group of lights with the blueprint (I have two switches that need to be operated).