Automation with alias 'set_heating_thermostat' could not be validated and has been disabled:?

I can’t figure out where to make the mistake ?

Home Assistant 2023.3.0.dev20230208
Frontend 20230208.0.dev - latest

    - id: setHeatingThermostat
      alias: set_heating_thermostat
      description: Set all heating thermostats at midnight
      initial_state: true
      mode: single

      trigger:
        - platform: time
          at: "01:00:00"

      condition:
        - condition: state
          alias: "Thermostat control activated"
          entity_id: input_boolean.heating_thermostat_enabled
          state: "on"

      action:
        - condition: state
          alias: "Thermostat control for holydays activated"
          entity_id: input_boolean.holiday_enabled
          state: "on"

        - service: climate.set_temperature
          data:
            temperature: "{{ states('input_number.thermostat_holiday_temp') | float }}"
          target:
            entity_id:
              - climate.thermostat_office
              - climate.thermostat_wc
              - climate.thermostat_kitchen
              - climate.thermostat_wohnzimmer1
              - climate.thermostat_wohnzimmer2
              - climate.thermostat_bad
              - climate.thermostat_kinderzimmer1
              - climate.thermostat_kinderzimmer2

        - condition: state
          alias: "Thermostat control for holydays deactivated"
          entity_id: input_boolean.holiday_enabled
          state: "off"

          sequence:
            - variables:
              newtemp: >-
                {% if is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')%}
                    {{ states('input_number.thermostat_summer') | float(0.00) }}
                {%else%}
                    {{ states('input_number.' ~ {{ repeat.item }}) | float(0.00) }}
                {% endif %}
            - repeat:
              for_each:
                - climate.thermostat_office
                - climate.thermostat_wc
                - climate.thermostat_kitchen
                - climate.thermostat_wohnzimmer1
                - climate.thermostat_wohnzimmer2
                - climate.thermostat_bad
                - climate.thermostat_kinderzimmer1
                - climate.thermostat_kinderzimmer2
                - thermostat_schlafzimmer
                - thermostat_fitnessraum
              sequence:
                - service: climate.set_temperature
                  data:
                    temperature: "{{ newtemp | float(0.00) }}"
                  target:
                    entity_id: "~ climate.{{ repeat.item }} ~"

                - delay:
                    milliseconds: 200

Error:

Automation with alias 'set_heating_thermostat' could not be validated and has been disabled: 
extra keys not allowed @ data['action'][2]['sequence']. 
Got [OrderedDict([('variables', None), ('newtemp', "{% if is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')%}\n 
{{ states('input_number.thermostat_summer') | float(0.00) }}\n{%else%}\n {{ states('input_number.' ~ {{ repeat.item }}) | float(0.00) }}\n{% endif %}")]), 
OrderedDict([('repeat', None), ('for_each', ['climate.thermostat_office', 'climate.thermostat_wc', 
'climate.thermostat_kitchen', 'climate.thermostat_wohnzimmer1', 'climate.thermostat_wohnzimmer2', 'climate.thermostat_bad',...

Can someone help me with that.
Thanks

newtemp needs to be indented by 2 spaces.

That’s not going to be a valid entity_id. get rid of the ~ and spaces between the " ".

You also have indentation issues with your foreach and repeat.

Your automation contains several fundamental syntax errors and at least one significant logic error. Compare the following corrected version to your original example.

    - id: setHeatingThermostat
      alias: set_heating_thermostat
      description: Set all heating thermostats at midnight
      initial_state: true
      mode: single

      trigger:
        - platform: time
          at: "01:00:00"

      condition:
        - condition: state
          alias: "Thermostat control activated"
          entity_id: input_boolean.heating_thermostat_enabled
          state: "on"

      action:
        if:
          - condition: state
            alias: "Thermostat control for holydays activated"
            entity_id: input_boolean.holiday_enabled
            state: "on"
        then:
          - service: climate.set_temperature
            data:
              temperature: "{{ states('input_number.thermostat_holiday_temp') | float }}"
            target:
              entity_id:
                - climate.thermostat_office
                - climate.thermostat_wc
                - climate.thermostat_kitchen
                - climate.thermostat_wohnzimmer1
                - climate.thermostat_wohnzimmer2
                - climate.thermostat_bad
                - climate.thermostat_kinderzimmer1
                - climate.thermostat_kinderzimmer2
        else:
          - variables:
              newtemp: >-
                {% if is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')%}
                  {{ states('input_number.thermostat_summer') | float(0) }}
                {%else%}
                  {{ states('input_number.' ~ repeat.item) | float(0) }}
                {% endif %}
          - repeat:
              for_each:
                - climate.thermostat_office
                - climate.thermostat_wc
                - climate.thermostat_kitchen
                - climate.thermostat_wohnzimmer1
                - climate.thermostat_wohnzimmer2
                - climate.thermostat_bad
                - climate.thermostat_kinderzimmer1
                - climate.thermostat_kinderzimmer2
                - climate.thermostat_schlafzimmer
                - climate.thermostat_fitnessraum
              sequence:
                - service: climate.set_temperature
                  data:
                    temperature: "{{ newtemp }}"
                  target:
                    entity_id: "climate.{{ repeat.item }}"
                - delay:
                    milliseconds: 200

Question for you:

When it’s a holiday, you set the temperature of all thermostats all at once. When it’s not a holiday, you set the temperature of each thermostat individually with a 200ms delay between each one. Why?

@Taras
Great, thank you very much. Now it works.
I forgot 200ms delay for the first part.

So the only difference between holidays and non-holidays is:

  • The target temperature you set the thermostats to (the value of input_number.thermostat_holiday_temp for holidays and the value of newtemp for non-holidays).

  • The quantity of thermostats (8 for holidays, 10 for non-holidays).

Is that correct? Or should the quantity of thermostats be the same (10)?

@123

The target temperature you set the thermostats to (the value of input_number.thermostat_holiday_temp for holidays and the value of newtemp for non-holidays).

Yes

The quantity of thermostats (8 for holidays, 10 for non-holidays).

Yes, because i do not need to set 2, because the default temp is lower than thermostat_holiday_temp.

But when i test the automation i got an error

UndefinedError: 'repeat' is undefined

That’s due to an error in one of your templates that I overlooked to correct.

The template you created for the newtemp variable references the repeat.item variable. However, repeat.item is undefined outside of the repeat loop.

You will have to redesign it.

Well he doesn’t need the newtemp variable, he can just put that in the loop and be done with it.

Yeah, that and possibly other tweaks; as far as basic mistakes go, this automation had more than it’s fair share… yet its author feels confident enough to be composing it for use on a development version of Home Assistant (2023.3.0.dev20230208). :man_shrugging:t3:

Thanks, You’re right

....
else:
          - repeat:
              for_each:
                - climate.thermostat_office
                - climate.thermostat_wc
                - climate.thermostat_kitchen
                - climate.thermostat_wohnzimmer1
                - climate.thermostat_wohnzimmer2
                - climate.thermostat_bad
                - climate.thermostat_kinderzimmer1
                - climate.thermostat_kinderzimmer2
                - climate.thermostat_schlafzimmer
                - climate.thermostat_fitnessraum
              sequence:
                - service: climate.set_temperature
                  data_template:
                    temperature:  >-
                      {% if is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')%}
                        {{ states('input_number.thermostat_summer') | float(0) }}
                      {%else%}
                        {{ states('input_number.' ~ repeat.item) | float(0) }}
                      {% endif %}
                    entity_id: "climate.{{ repeat.item }}"

                - service: script.infomessagegotify
                  data_template:
                    title: "{{'Heizungssteuerung - Urlaub aus'}}"
                    message: "Thermostat {{ repeat.item }} wurden am: {{ now().strftime('%Y-%m-%d %H:%M:%S') }} auf {{ states('sensor.thermostat_hc1_summer_mode') }} eingestellt."
...
1 Like

FWIW, you don’t even need an if-else. All you need to do is one repeat where the quantity of thermostats (8 or 10) is based on whether it’s a holiday or not.

BTW, data_template was deprecated in favor of simply data many versions ago. Don’t rely on archaic examples (over a year old) to create new automations.

Thanks for the tip. but that only works with if then…or because I don’t know how I could distinguish the two cases without condition

Here’s what I meant when I suggested to adjust the quantity of thermostats based on whether it’s a holiday or not.

    - id: setHeatingThermostat
      alias: set_heating_thermostat
      description: Set all heating thermostats at midnight
      initial_state: true
      mode: single
      trigger:
        - platform: time
          at: "01:00:00"
      condition:
        - condition: state
          entity_id: input_boolean.heating_thermostat_enabled
          state: "on"
      action:
        - variables:
            base:
              - thermostat_office
              - thermostat_wc
              - thermostat_kitchen
              - thermostat_wohnzimmer1
              - thermostat_wohnzimmer2
              - thermostat_bad
              - thermostat_kinderzimmer1
              - thermostat_kinderzimmer2
            thermostats: >
              {{ base if is_state('input_boolean.holiday_enabled', 'on') 
                else base + ['thermostat_schlafzimmer', 'thermostat_fitnessraum'] }}
        - repeat:
            for_each: "{{ thermostats }}"
            sequence:
              - service: climate.set_temperature
                data:
                  temperature: >
                    {{ states('input_number.thermostat_summer') if is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')
                      else states('input_number.' ~ repeat.item) }}
                target:
                  entity_id: "climate.{{ repeat.item }}"
              - delay:
                  milliseconds: 200

Yes better, but i have 3 cases:

  • Sommermode : 30 °C (all Thermostats are open)
  • Wintermode: … based on the Room settings: states('input_number.' ~ repeat.item) }}
  • Holdyday mode: based on states('input_number.thermostat_summer')

But I think I can solve the data: temperature.
Must try tomorrow.

Thank you for the support and the time :+1:

Now that would be my solution:

I use the min, max, value attribute from the input_number.thermostat* for the 3 cases (vacation, winter, summer). This enables me to set my own values for each thermostat.

But it looks like he won’t run Trigger at: “00:30:00”.
I can trigger it manually.

  - id: setHeatingThermostat
      alias: "Heizungsthermostate einstellen"
      description: "Setzen der Thermostate Urlaub, Sommer- oder Winterbetrieb"
      initial_state: true
      mode: single
      trigger:
        - platform: time
          at: "00:30:00"
      condition:
        - condition: state
          alias: "Ausführen wenn Thermostate Temperatur aktiviert wurde."
          entity_id: input_boolean.heating_thermostat_enabled
          state: "On"
      action:
        - variables:
            thermostats:
              - thermostat_office
              - thermostat_wc
              - thermostat_kitchen
              - thermostat_wohnzimmer1
              - thermostat_wohnzimmer2
              - thermostat_bad
              - thermostat_kinderzimmer1
              - thermostat_kinderzimmer2
              - thermostat_schlafzimmer
              - thermostat_fitnessraum
        - repeat:
            for_each: "{{ thermostats }}"
            sequence:
              - service: climate.set_temperature
                alias: "Set the selected thermostat temperature"
                data:
                  temperature: >-
                      {%if is_state("input_boolean.holiday_enabled","on") %}
                        {{ state_attr('input_number.' ~ repeat.item,'min') | float(0.00) }}
                      {%elif is_state('sensor.thermostat_hc1_summer_mode', 'Sommer')%}
                      {{ state_attr('input_number.' ~ repeat.item,'max') | float(0.00) }}
                      {%else%}
                        {{ states('input_number.' ~ repeat.item) | float(0.00) }}
                      {%endif%}
                target:
                  entity_id: "climate.{{ repeat.item }}"
              - delay:
                  milliseconds: 200
              - service: script.infomessagegotify
                alias: "Send info message to gotify"
                data:
                  title: "{{'Heizungssteuerung - Thermostate'}}"
                  message: "Thermostat {{ repeat.item }} wurden am: {{ now().strftime('%Y-%m-%d %H:%M:%S') }} auf {{ state_attr('climate.' ~ repeat.item,'temperature') | float(0.00) }} °C eingestellt."

You have misunderstood how the Solution tag is used in this community forum.

You marked your own post with the Solution tag but it is based entirely on the example I provided for you in this post.

The example I had provided corrected all the errors in your first post (there were about 10 errors). In fact, you originally marked my post as the Solution. Then you added a few minor requirements, that were not part of the first post, and marked your own post as the Solution.

The Solution tag is assigned to the first, or best, post that resolves the problems originally presented. Refer to guideline 21 in the FAQ.

Please consider adhering to the guidelines of this community forum and use the Solution tag as intended. Thank you.


Note

The example in your latest post re-introduces unnecessary practices and serves to mislead other users into believing that they may be required when, in fact, they are not.

Yes, sorry…