Aircon switch back off

Hello,

I have 3 aircons :

climate.airco_gang
climate.airco_living_links
climate.airco_living_rechts

They are all turned on using the same script :

alias: 'Switch : Airco x op y graden'
description: Set airco mode to heat and set temperature
fields:
  temperature:
    description: The temperature to set the airco at
    default: 22
    example: '21'
  entity_id:
    description: The climate entity you want to control
    default: climate.airco_gang
    example: climate.airco_gang
sequence:
  - repeat:
      sequence:
        - service: climate.turn_on
          target:
            entity_id: '{{ entity_id }}'
        - service: climate.set_hvac_mode
          target:
            entity_id: '{{ entity_id }}'
          data:
            hvac_mode: heat
        - service: climate.set_temperature
          data:
            temperature: '{{ temperature }}'
          target:
            entity_id: '{{ entity_id }}'
        - service: climate.set_fan_mode
          data:
            fan_mode: auto
          target:
            entity_id: '{{ entity_id }}'
      until:
        - condition: template
          value_template: '{{ repeat.index >= 1 }}'
mode: single

When f.e. I come home, the aircons switches on via this automatisation :

alias: Tussentijdse acties bij thuiskomst
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.toggle_christian_bostoen_is_thuis
    to: 'on'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.toggle_airco_living
            state: 'on'
        sequence:
          - service: script.switch_airco_x_op_y_graden
            data:
              temperature: >-
                {{
                states('input_number.temperatuur_airco_living_tijdens_de_dag')}}
              entity_id: climate.airco_living_links
          - delay:
              seconds: 5
          - service: script.switch_airco_x_op_y_graden
            data:
              temperature: >-
                {{
                states('input_number.temperatuur_airco_living_tijdens_de_dag')}}
              entity_id: climate.airco_living_rechts
          - delay:
              seconds: 5
    default: []
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.toggle_airco_gang
            state: 'on'
        sequence:
          - service: script.switch_airco_x_op_y_graden
            data:
              temperature: '{{ states(''input_number.temperatuur_airco_gang'')}}'
              entity_id: climate.airco_gang
    default: []
...
mode: single

The problem is now that this doesn’t work every time…sometimes there is one aircon not on (not always the same one !).

I created these sensors to keep track if an aircon is on or off :

- binary_sensor:
    - name: "airco_gang_is_on"
      icon: "mdi:fan"
      state: "{{ not is_state('climate.airco_gang', 'off') }}"
    - name: "airco_living_links_is_on"
      icon: "mdi:fan"
      state: "{{ not is_state('climate.airco_living_links', 'off') }}"
    - name: "airco_living_rechts_is_on"
      icon: "mdi:fan"
      state: "{{ not is_state('climate.airco_living_rechts', 'off') }}"

And if the state changes I send myself an e-mail.

I left my house and I received 3 e-mails :

Schermafbeelding 2022-01-22 175539

But when I came back I received these e-mails :

Schermafbeelding 2022-01-22 175732

As you can see my “Airco living links” is first switched on, but also switched off after.

In my script “Airco x op y graden” I already have my repeat routine, that I now run twice to solve this but of course I would prefer to find the reason…

I already put some delay’s (the 5 seconds), but this doesn’t work.

Somebody an idea ?