- alias: 'Climate Auto Mode'
initial_state: true
trigger:
- platform: state
entity_id: climate.mi_acpartner_playroom_2, climate.mi_acpartner_bedroom
condition:
- condition: template
value_template: "{{ (trigger.to_state.state != 'unavailable') and (trigger.to_state.state != 'off') }}"
action:
- service: climate.set_temperature
data_template:
entity_id: '{{ trigger.entity_id }}'
temperature: 26
hvac_mode: >
{% if ((now().month >= 11) or (now().month <= 3)) and (trigger.to_state.state != 'heat') %}
'heat'
{% elif ((now().month >= 6) and (now().month <= 10)) and (trigger.to_state.state != 'cool') %}
'cool'
{% else %}
'auto'
{% endif %}
When entity triggered this automation…
Error while executing automation automation.climate_auto_mode. Invalid data for call_service at pos 1: value is not allowed for dictionary value @ data[‘hvac_mode’]
Which version of home assistant are you running? If you go to Developer Tools -> Services and choose “chlimate.set_temperature” do you see “hvac_mode” as one of the parameters?
I recall a similar problem while helping someone else. I performed the test using an older version of Home Assistant that employs operation_mode instead of the newer hvac_mode.
When I used the Services page to call set_temperature, I could specify both the desired temperature and the operation_mode. However, when I tried to do the same thing with an automation, Config Check complained that operation_mode is an “extra key”.
That’s not the same error as you have but still highlights a discrepancy between using the Services page and an automation.
I have not yet repeated the test using a newer version of Home Assistant.
Does the automation also work if you force it to “cool” without if …else…?
I ask this because I remeber having read something about not being able to set to “cool” if a temperature is provided.
Did some test here.
If the thermostat in off state, I just can’t turn it on by climate.set_temperature service, tried heat/auto/cool, no feedback at all and no errors in log.
Then I called climate.turn_on to turn on it first, the climate.set_temperature service works good.
That makes sense. Glad you figured it out! Now that I think about it I think I had the same problem when I did my climate automations a while back. You should probably mark your comment as the solution so anyone else coming across the thread sees it right away.