Help with climate data_template

Yes. I don’t think the quotes were ever the issue here.

This should be a helpful page for you, especially the templates section.

https://developers.home-assistant.io/docs/en/documentation_standards.html

Thanks, I will try my best to understand this… :rofl:

The goal of this automation appears to be the prevent the thermostat from being set to a temperature and mode that are inappropriate for a given month. In fact, there are only two months when the thermostat is allowed to be used without constraints. Is this correct?

My solution was based on the original automation which I interpreted as:

  • November thru March, always set hvac to heat mode, regardless of user setting
  • June thru October, always set the hvac to cool, regardless of user setting
  • April and May, always set the hvac mode to auto, regardless of user setting
  • The temperature would always be set to 26 degrees no matter the mode. (Personally I don’t think that is desirable so I tried to show how he could adjust it for different time periods with the hvac mode.)

The last automation he posted approaches it quite differently also with no temperature being set. It’s actually seems like a more logical way to approach it so kudos to him for working it out.

I approach my climate automation from an entirely different angle. It was fun trying to figure this one out though. Definitely had me stumped for a bit! :upside_down_face:

BTW this automation would never fly at my place. I guarantee we’d get a freak cold snap in June when I’m outta town and the wife would try to put the heat on. I’d come home to my Nest in pieces in the trash and a $200 bill from the schmuck that installed the replacement while I was gone :rofl:

The motivation I create this automation is my climates sometimes always set to ‘cold’ if I call climate.turn_on service, so I am trying to set to ‘heat’ in winter automatically.

:joy:

BTW, base on my latest config, manual temperature change doesn’t trigger the automation, which means I can still change the target temperature.

- alias: 'Climate Auto Mode'   
  initial_state: true
  trigger:
  - platform: state
    entity_id: climate.mi_acpartner_playroom_2, climate.mi_acpartner_bedroom  
  condition:
    condition: or
    conditions:
    - condition: template
      value_template: "{{ (trigger.to_state.state == 'heat') and  ((now().month >= 6) and (now().month <= 10)) }}"
    - condition: template
      value_template: "{{ (trigger.to_state.state == 'cool') and  ((now().month >= 11) or (now().month <= 3)) }}"  
  action:
  - service: climate.set_temperature
    data_template:
      entity_id: '{{ trigger.entity_id }}'
      temperature: 26
      hvac_mode: >
        {% if trigger.to_state.state == 'cool' %}
          heat
        {% elif trigger.to_state.state == 'heat' %}
          cool
        {% else %}
          auto
        {% endif %}

That would have been helpful information in step one! I probably over thought this one…lol
So if that’s all you’re trying to accomplish why use climate.set_temperature and not just climate.set_hvac_mode? I thought you had dropped the temperature set, you had only posted part of your automation!

I would be curious to find out what happens if you went to your thermostat right now and set the temperature to 30 and then set the mode to cool, in that order.

Sorry for the missing part… I really only focused on the error that time. :sweat_smile:

I didi what you asked, it worked as expected.

  1. Turn on thermostat.
  2. Trigger the automation and set to ‘heat’ to 26 degree
  3. Set the temperature to 30.
  4. Set to cool.
  5. Trigger the automation, back to ‘heat’ to 26.

So you do want to force the temp to 26. Gotcha! I guess you’re all set then!

Yeah, I just want to set a default comfortable temperature, thank you so much Jason. :clap: