Thermostats automation not working correctly

Hi all,

Since the start of this year’s heating season, I have had problems with the automation of my thermostats, everything works as it should for me but manually only. I have 6 of these thermostats connected with Z2M, and automation setup like this:

alias: Topení
description: ""
trigger:
  - platform: time
    at: "06:00:00"
    id: Obyvak ON
    alias: Obyvak ON
  - platform: time
    at: "23:00:00"
    id: Obyvak Off
    alias: Obyvak Off
  - platform: time
    at: "06:00:00"
    id: Kuchyne ON
    alias: Kuchyne ON
  - platform: time
    at: "09:30:00"
    id: Kuchyne zmena teploty
    alias: Kuchyne zmena teploty
  - platform: time
    at: "20:00:00"
    id: Kuchyne OFF
    alias: Kuchyne OFF
  - alias: Pokojicek ON
    platform: time
    at: "12:00:00"
    id: Pokojicek ON
  - alias: Pokojicek OFF
    platform: time
    at: "18:00:00"
    id: Pokojicek OFF
  - alias: Koupelna ON
    platform: time
    at: "18:00:00"
    id: Koupelna ON
  - alias: Koupelna OFF
    platform: time
    at: "21:00:00"
    id: Koupelna OFF
condition: []
action:
  - alias: Obyvak
    choose:
      - conditions:
          - condition: trigger
            id:
              - Obyvak ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              device_id: caaa3250d5d0f3a452629ad985155557
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 22
            target:
              device_id: caaa3250d5d0f3a452629ad985155557
      - conditions:
          - condition: trigger
            id:
              - Obyvak Off
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              device_id: caaa3250d5d0f3a452629ad985155557
  - alias: Kuchyně
    choose:
      - conditions:
          - condition: trigger
            id:
              - Kuchyne ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              device_id:
                - de0ec57fe1a158b75e708b2659a3926b
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 22
            target:
              device_id:
                - de0ec57fe1a158b75e708b2659a3926b
      - conditions:
          - condition: trigger
            id:
              - Kuchyne zmena teploty
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 19
            target:
              device_id: de0ec57fe1a158b75e708b2659a3926b
      - conditions:
          - condition: trigger
            id:
              - Kuchyne OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              device_id: de0ec57fe1a158b75e708b2659a3926b
  - alias: Pokojíček
    choose:
      - conditions:
          - condition: trigger
            id:
              - Pokojicek ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              device_id:
                - 5b2b956f5c18a0f4f6543154ef27fc38
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 21
            target:
              device_id: 5b2b956f5c18a0f4f6543154ef27fc38
      - conditions:
          - condition: trigger
            id:
              - Pokojicek OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              device_id: 5b2b956f5c18a0f4f6543154ef27fc38
  - alias: Koupelna
    choose:
      - conditions:
          - condition: trigger
            id:
              - Koupelna ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              device_id: 92040d0e8325347a197f714dc06f0be9
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 21
            target:
              device_id: 92040d0e8325347a197f714dc06f0be9
      - conditions:
          - condition: trigger
            id:
              - Koupelna OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              device_id: 92040d0e8325347a197f714dc06f0be9
mode: single

I looked into traces and automation triggered correctly (at least visually) but thermostat stays off (in this example):

Everithing was working correctly last winter, but without changing anything this fall it suddenly starts behaving strangely.
Usualy the automation turn thermostat on or off, but not always, and cannot change the temperature at all. I need tu check it during the day and correct it.

Do you have any ideas where to start? I’ve tried everything I can think of like add delays, use auto and heat mode, new batteries, reconnect devices.

Have you tried running this in Developer Tools → Services to see if it’s engaging your thermostat by pasting the exact YAML you are attempting to run into the tool? You could also try removing the “device_id” and instead using the “entity_id” of the device. If the overall process seems to be running but the services aren’t, then double checking your services is a good place to start diagnosing the issue.

I’ve had some problems with automations recently, I found out that I had to change to mode: restart to make them work again.

I tried call services and it react the same as automation, sometime it work, sometime not. I change mode to restart in the automation YAML, as @bouwew recomended, hopefully it will help.
Thank you both, I will let you know tomorow if it helps.

So, I cleaned configuration.yaml and sensors.yaml, changed device to entity and automation to restart mode and it worked this morning almost perfectly. But restart mode interrupt one automation in process so I swich to paralel mode, since at least 2 triggers starts at the same time. Thank you both for your help.

Thank you for your help, but I´m still struggling with climate services, both in automation and in manual settings, when the change is reflected in 50% of cases. Can you please guide me how to check the climate services you mention?

It’s just a matter of running your commands in Developer → Services then comparing the YAML that is working to the YAML you are running in your automation.

In general, and perhaps this is part of the issue, you should be triggering off an entity rather than a device (i.e., most of your YAML points to “device_id” instead of an entity in the device as “entity_id”).

I changed my automation to trigger entities, now it looks like this:

alias: Topení
description: ""
trigger:
  - platform: time
    at: "06:00:00"
    id: Obyvak ON
    alias: Obyvak ON
  - platform: time
    at: "23:00:00"
    id: Obyvak Off
    alias: Obyvak Off
  - platform: time
    at: "06:00:00"
    id: Kuchyne ON
    alias: Kuchyne ON
  - platform: time
    at: "09:30:00"
    id: Kuchyne zmena teploty
    alias: Kuchyne zmena teploty
  - platform: time
    at: "20:00:00"
    id: Kuchyne OFF
    alias: Kuchyne OFF
  - alias: Pokojicek ON
    platform: time
    at: "12:00:00"
    id: Pokojicek ON
  - alias: Pokojicek OFF
    platform: time
    at: "18:00:00"
    id: Pokojicek OFF
  - alias: Koupelna ON
    platform: time
    at: "18:00:00"
    id: Koupelna ON
  - alias: Koupelna OFF
    platform: time
    at: "21:00:00"
    id: Koupelna OFF
condition: []
action:
  - alias: Obyvak
    choose:
      - conditions:
          - condition: trigger
            id:
              - Obyvak ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.termostat_obyvak
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 22
            target:
              entity_id: climate.termostat_obyvak
      - conditions:
          - condition: trigger
            id:
              - Obyvak Off
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.termostat_obyvak
  - alias: Kuchyně
    choose:
      - conditions:
          - condition: trigger
            id:
              - Kuchyne ON
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: heat
            target:
              entity_id: climate.termostat_kuchyne
          - delay:
              hours: 0
              minutes: 1
              seconds: 0
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 22
            target:
              entity_id: climate.termostat_kuchyne
      - conditions:
          - condition: trigger
            id:
              - Kuchyne zmena teploty
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 19
            target:
              entity_id: climate.termostat_kuchyne
      - conditions:
          - condition: trigger
            id:
              - Kuchyne OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.termostat_kuchyne
  - alias: Pokojíček
    choose:
      - conditions:
          - condition: trigger
            id:
              - Pokojicek ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.termostat_pokojicek
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 21
            target:
              entity_id: climate.termostat_pokojicek
      - conditions:
          - condition: trigger
            id:
              - Pokojicek OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.termostat_pokojicek
  - alias: Koupelna
    choose:
      - conditions:
          - condition: trigger
            id:
              - Koupelna ON
        sequence:
          - service: climate.turn_on
            data: {}
            target:
              entity_id: climate.termostat_koupelna
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - service: climate.set_temperature
            data:
              temperature: 21
            target:
              entity_id: climate.termostat_koupelna
      - conditions:
          - condition: trigger
            id:
              - Koupelna OFF
        sequence:
          - service: climate.turn_off
            data: {}
            target:
              entity_id: climate.termostat_koupelna
mode: parallel
max: 10

But I dont thing that this is related to automation, since this problem also occurs when controlling the entity from the lovelace. Its maybe signal related or something on the background is disturbing my input or automation.