Set thermostat temperature from schedule conditions

Hi,
I am trying to set the temperature on a thermostatic radiator valve (TRV) thermostat (climate.lumi_lumi_airrtc_agl001_thermostat_3) based on a schedule.

I have created a schedule called schedule.thermostat_schedule_bedroom which can be “off” or “on”.
When it is “off”, I want the TRV temperature = 7, and when it is “on”, TRV temp = 17.

I have tried to write the following automation to test for the “on”/“off” conditions. However, it does not control the temperature when the automation is run.

Any advice on how to write an automation with conditions based on the schedule state would be much appreciated. I am fairly new to HA.

trigger:
  - platform: state
    entity_id: schedule.thermostat_schedule_bedroom
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state in ['off'] }}"
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.lumi_lumi_airrtc_agl001_thermostat_3
            data:
              temperature: 7
              hvac_mode: heat
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state in ['on'] }}"
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.lumi_lumi_airrtc_agl001_thermostat_3
            data:
              temperature: 17
              hvac_mode: heat
mode: single

alias: example
trigger:
  - platform: state
    entity_id: schedule.thermostat_schedule_bedroom
condition: []
action:
  - service: climate.set_temperature
    target:
      entity_id: climate.lumi_lumi_airrtc_agl001_thermostat_3
    data:
      temperature: "{{ iif(trigger.to_state.state == 'on', 17, 7) }}"
      hvac_mode: heat
mode: single

Be advised that the automation uses trigger.to_state.state so it can’t be tested by executing its Run command.

To test it, the value of schedule.thermostat_schedule_bedroom must change from one state to another. You can either wait for this to occur naturally (based on the schedule you have created) or you can force it by going to Developer Tools → States, select schedule.thermostat_schedule_bedroom, scroll to the top of the page, and manually set its state to on (assuming its currently off). This should be sufficient to trigger the automation’s State Trigger.

Note

Be sure your TRV allows for setting a target temperature as low as 7.

2 Likes