Noob automation question

Hi.
I have written my first automation to change 2 thermostat temps. at a certain time during work days (please see below). I must have a syntax error as only the first one (south) works. Some help please with getting both to work. Thanks in advance.

  • action:
    • service: climate.set_temperature
      data:
      #(Living Room S - Thermostat)
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_2
      temperature: 21.0
      alias: Work day temp raise-S
      condition:

    • condition: state
      entity_id: binary_sensor.workday_sensor
      state: ‘on’
      id: ‘1522242928768’
      trigger:

    • at: ‘15:30:00’
      platform: time

    • service: climate.set_temperature
      data:
      #(Living Room N - Thermostat)
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_3
      temperature: 20.5
      alias: Work day temp raise-N
      condition:

    • condition: state
      entity_id: binary_sensor.workday_sensor
      state: ‘on’
      id: ‘1522242928768’
      trigger:

    • at: ‘15:30:00’
      platform: time

Hard to tell without the right formatting, use the Preformatted Text button </>

Hmm, attached the file as seemed quicker automations.yaml (781 Bytes)

:grinning:

most people won’t download your yaml to debug it.

Paste it in the reply box, highlight all of the code, and push the </> button

Ok, thanks for the tip :slight_smile:

- action:
  - service: climate.set_temperature
    data:
      # (Living Room S - Thermostat)
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_2
      temperature: 21.0
  alias: Work day temp raise-S
  condition:
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  id: '1522242928768'
  trigger:
  - at: '15:30:00'
    platform: time

  - service: climate.set_temperature
    data:
      # (Living Room N - Thermostat)
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_3
      temperature: 20.5
  alias: Work day temp raise-N
  condition:
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  id: '1522242928768'
  trigger:
  - at: '15:30:00'
    platform: time

I am not 100% on this, but the Climate component docs say that operation mode is not optional. They give this example:

CORRECTION: It IS optional.

automation:
  trigger:
    platform: time
    at: "07:15:00"
  action:
    - service: climate.set_temperature
      data:
        entity_id: climate.kitchen
        temperature: 24
        operation_mode: Heat
- condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  id: '1522242928768'

Is the id: part needed?

automation:
  alias: Turn on heater on workdays
  trigger:
    platform: time
    at: '08:00:00'
  condition:
    condition: state
    entity_id: 'binary_sensor.workday_sensor'
    state: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.heater

ID is ONLY needed if you want to see it in the frontend automation editor.

1 Like

That is what threw me off. I don’t use the frontend editor. Does the frontend editor “flip” the order of things too? I always put my trigger first.

Can you explain what you are trying to do here?

Your formatting still seems off. How do both automations fall under ONE - action:?

Was this done in the automation editor?

I think this entire automations.yaml is jacked up. - action: should not be the root of the file, with the automations under it. each automation should have a root on the file.

Try this:

- alias: Work day temp raise-S
  id: '1522242928768'
  trigger:
    at: '15:30:00'
    platform: time
  condition:
    condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  action:
    - service: climate.set_temperature
      data:
        # (Living Room S - Thermostat)
        entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_2
        temperature: 21.0

- alias: Work day temp raise-N
  id: '1522242928768'
  trigger:
    at: '15:30:00'
    platform: time
  condition:
    condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  action:
    - service: climate.set_temperature
      data:
        # (Living Room N - Thermostat)
        entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_3
        temperature: 20.5

Ugh. Yes. The frontend editor is a great idea, but it’s impossible to get it to put things in a logical order it seems.

@flamingm0e @ericleejoe

The frontend editor places everything in alphabetical order. It simply prints an ordered dictionary. So everything at a specific indent level will be in alphabetical order:

- alias: foo
  trigger: ...
  condition: ...
  action: ....

will turn into this when saved:

- action:...
  alias: foo
  condition: ...
  trigger: ...

Knowing this will help you find your crap if you use the automation wiz

1 Like

I started writing the automation in the editor, but when it didn’t work and I checked the example documentation for the climate automation, I edited the file directly.
Now I understand the discrepancy in the order as petro explained (thanks).
What I am trying to do basically is to get both thermostats (which are at opposite ends of the same room) to change temps at the same time each working day but with slightly different temperatures. When working, I will just copy to make a similar automation to reduce the temps again in the late evening.