My first automation (help needed)

Hello,

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 :slight_smile:

My setup:

  • I have 4 nests which control in-floor electrovalves:
  1. sensor.bedroom_thermostat_hvac_state (off / heating)
  2. sensor.attic_thermostat_hvac_state (off / heating)
  3. sensor.living_room_thermostat_hvac_state (off / heating)
  4. sensor.master_bedroom_thermostat_hvac_state (off / heating)

Unfortunately I was not smart enough to create nest zones the proper way (using a damper to control the central heating unit).

  • My central heating unit is controlled by a zwave relay (on/off)
  1. switch.central_heating_switch

What I’m trying to do is the following:

  1. if one of the nests are in ‘heating’ turn the zwave relay on
  2. if all nests are off turn the zwave relay off

Any suggestions on how to do this?
Do I need to create multiple automation with conditions?
Is appdaemon more suitable than normal automations?

Thanks.

One automation.

Trigger on state change of any of the 4 thermostats.

  trigger:
    platform: state
    entity_id: sensor.bedroom_thermostat_hvac_state,sensor.attic_thermostat_hvac_state, sensor.living_room_thermostat_hvac_state, sensor.master_bedroom_thermostat_hvac_state

No conditions necessary

Use a template to determine which service to call:

I don’t know how your sensors indicate “heating”, but for this example I’ll assume that is their state.

service_template: >
  {% if states.sensor.bedroom_thermostat_hvac_state.state = 'heating' or ... or ... or ... %}
    switch.turn_on
  {% else %}
    switch.turn_off
  {% endif %}
entity_id: switch.central_heating_switch

Something like:

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
1 Like

Hi, thanks for the quick reply.
However I cannot create the automation, it keeps telling me: “[state] is an invalid option for [automation]”

What is wrong with this: https://pastebin.com/SPCmSyAH

Thanks

Thanks for the detailed example.
The grouping it does not seem to work. When one of the sensors are ‘heating’ the group is still off.

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.

Then use the first automation :wink:

What version of Home Assistant are you running, if it’s not 0.55 (or later) you should upgrade.

Thank you all for your help.
It is working now. Here is the configuration: - alias: 'Toggle heating' trigger: - platform: state - Pastebin.com

Thank you. I was using this in the config and an older automation was causing the error message:

automation: !include_dir_merge_list includes/automations

I’m using 0.55.2 in docker.

Just for information, I have the UK version of the nest which is only for heating.
Here are the entities:

  • sensor.master_bedroom_thermostat_humidity
  • sensor.master_bedroom_thermostat_hvac_state (off/heating)
  • sensor.master_bedroom_thermostat_operation_mode (off/heat/eco)
  • sensor.master_bedroom_thermostat_target
  • sensor.master_bedroom_thermostat_temperature
  • binary_sensor.master_bedroom_thermostat_online
  • climate.master_bedroom:
    current_temperature: 22.5
    min_temp: 9
    max_temp: 32
    temperature: 22
    operation_mode: heat
    operation_list: off,heat,eco
    away_mode: off
    unit_of_measurement: °C
    friendly_name: Master Bedroom