I’ve been using hass for some time but now it’s time for my first automation. For me, automations look simple to understand until you I needed to create one
My setup:
I have 4 nests which control in-floor electrovalves:
automation:
- alias: 'Nest heating'
trigger:
# Multiple triggers are OR - so if either are in the 'heating' state
- platform: state
to: 'heating'
entity_id: sensor.bedroom_thermostat_hvac_state
- platform: state
to: 'heating'
entity_id: sensor.attic_thermostat_hvac_state
- platform: state
to: 'heating'
entity_id: sensor.living_room_thermostat_hvac_state
- platform: state
to: 'heating'
entity_id: sensor.master_bedroom_thermostat_hvac_state
action:
service: switch.turn_on
entity_id: switch.central_heating_switch
And then:
- alias: 'Nest heating'
trigger:
# Multiple triggers are OR - so if either are in the 'heating' state
- platform: state
to: 'off'
entity_id: sensor.bedroom_thermostat_hvac_state
- platform: state
to: 'off'
entity_id: sensor.attic_thermostat_hvac_state
- platform: state
to: 'off'
entity_id: sensor.living_room_thermostat_hvac_state
- platform: state
to: 'off'
entity_id: sensor.master_bedroom_thermostat_hvac_state
condition:
condition: and
- conditions:
- condition: state
state: 'off'
entity_id: sensor.bedroom_thermostat_hvac_state
- condition: state
state: 'off'
entity_id: sensor.attic_thermostat_hvac_state
- condition: state
state: 'off'
entity_id: sensor.living_room_thermostat_hvac_state
- condition: state
state: 'off'
entity_id: sensor.master_bedroom_thermostat_hvac_state
action:
service: switch.turn_on
entity_id: switch.central_heating_switch
Now, you might find that you can create a group with the sensors, and that the group becomes heating when any one is heating, and off when all are off. If that is the case:
group:
my_nests
view: false
name: My Nest thermostats
entities:
- sensor.bedroom_thermostat_hvac_state
- sensor.attic_thermostat_hvac_state
- sensor.living_room_thermostat_hvac_state
- sensor.master_bedroom_thermostat_hvac_state
automation:
- alias: 'Nest heating'
trigger:
# Multiple triggers are OR - so if either are in the 'heating' state
- platform: state
to: 'heating'
entity_id: group.my_nests
action:
service: switch.turn_on
entity_id: switch.central_heating_switch
- alias: 'Nest heating'
trigger:
# Multiple triggers are OR - so if either are in the 'heating' state
- platform: state
to: 'off'
entity_id: group.my_nests
action:
service: switch.turn_on
entity_id: switch.central_heating_switch
I pasted that automation code into my test system and it did not generate any errors.
Are you using the gui automation editor? I don’t use that so I’m afraid I can’t help if that is the case.
If you are using separate files, perhaps that is the issue.
For automation files I use a merge directory like this:
automation: !include_dir_merge_list automation
Perhaps the issue is with how this is set up in your configuration.yaml.
I do want to point out that by setting the “initial_state” to “off” you are disabling this automation.
It will never run until you enable it either with the gui or with a service call.