I have a need to keep two groups of entities in sync, but rather than keep them the same (i.e. both on), I need one group to be ‘on’ and the other to be ‘off’ or vice versa. The application is making sure that zone heating schedules are either in heating, or energy saver modes - I don’t want both to be enabled at the same time. So rather than loads of automations, I had a go at creating my first blueprint.
I have no doubt that the more experienced among you will find ways to improve it, and I am keen to learn. Anyway, here is my humble offering!
blueprint:
name: Entity State Not
description: Sync the states of two groups of entities so that Group 1 != Group 2
domain: automation
input:
group1:
name: Entity Group 1
selector:
entity:
multiple: true
group2:
name: Entity Group 2
selector:
entity:
multiple: true
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: !input group1
to: 'on'
id: group1_on
- platform: state
entity_id: !input group1
to: 'off'
id: group1_off
- platform: state
entity_id: !input group2
to: 'on'
id: group2_on
- platform: state
entity_id: !input group2
to: 'off'
id: group2_off
action:
- choose:
- conditions:
- condition: trigger
id:
- group1_on
- group2_off
sequence:
- service: homeassistant.turn_on
target:
entity_id: !input group1
- service: homeassistant.turn_off
target:
entity_id: !input group2
- conditions:
- condition: trigger
id:
- group2_on
- group1_off
sequence:
- service: homeassistant.turn_on
target:
entity_id: !input group2
- service: homeassistant.turn_off
target:
entity_id: !input group1