I want to warm up a cold room. The colder the room is, the longer it will take to warm up.
I basically want the target temp to be 70F by 5:30pm. So I’m thinking something like:
If day is mon tue wed thu sat sun (so not friday)
If time is 2pm and temp < 45 then set temp to 69
if time is 3pm and temp < 55 then set temp to 69
if time is 4pm and temp < 65 then set temp to 69
What’s the best way to go about that?
Thank you!
There are a bunch of ways to do it, the “best way” for any user is one they understand.
Here’s are two approaches (click the arrows to see each configuration):
A single Time trigger with three times and the weekdays. Using And conditions within an Or condition to pair Time and Temperature requirements.
triggers:
- trigger: time
at:
- "14:00:00"
- "15:00:00"
- "16:00:00"
weekday:
- "mon"
- "tue"
- "wed"
- "thu"
- "sat"
- "sun"
conditions:
- or:
- and:
- condition: time
before: "14:01:00"
- condition: numeric_state
entity_id: sensor.YOUR_TEMP
below: 45
- and:
- condition: time
before: "15:01:00"
after: "14:59:00"
- condition: numeric_state
entity_id: sensor.YOUR_TEMP
below: 55
- and:
- condition: time
before: "16:01:00"
after: "15:59:00"
- condition: numeric_state
entity_id: sensor.YOUR_TEMP
below: 65
actions:
- action: climate.set_temperature
target:
entity_id: climate.YOUR_THERMOSTAT
data:
temperature: 69
hvac_mode: heat
Note: If you are using the current temperature attribute from your thermostat instead of a sensor entity, the conditions will need to be modified as follows:
- condition: numeric_state
entity_id: climate.YOUR_THERMOSTAT
attribute: current_temperature
below: 65
Multiple Time triggers. Pair time and temperature requirements by assigning the temperature value to a variable for each trigger. Then using conditions to check weekday and compare variable value to sensor state.
triggers:
- trigger: time
at: "14:00:00"
variables:
temp: 45
- trigger: time
at: "15:00:00"
variables:
temp: 55
- trigger: time
at: "16:00:00"
variables:
temp: 65
conditions:
- not:
- condition: time
weekday: "fri"
- condition: template
value_template: "{{ states('sensor.YOUR_TEMP')|float(0) < temp }}"
actions:
- action: climate.set_temperature
target:
entity_id: climate.YOUR_THERMOSTAT
data:
temperature: 69
hvac_mode: heat
Note: If you are using the current temperature attribute from your thermostat instead of a sensor entity, the template for the condition will be:
{{ state_attr('climate.YOUR_THERMOSTAT', 'current_temperature' ) < temp }}
1 Like
Arh
March 6, 2026, 4:43pm
3
Use the generic thermostat integration and set the preset temps. Then use a time trigger to switch between presets. This will also allow a manual overide if needed.
OP seems to already have a thermostat…
Thank you, I will study those and try them.
So this is the yaml I’m attempting to use, the problem is, at 2pm it’s setting the temperature to 69, even if the current temperature is above 45.
alias: Sunroom Temperature
description: ""
triggers:
- trigger: time
at: "14:00:00"
variables:
temp: 45
- trigger: time
at: "15:00:00"
variables:
temp: 55
- trigger: time
at: "16:30:00"
variables:
temp: 65
conditions:
- not:
- condition: time
weekday: fri
- condition: template
value_template: >-
{{ state_attr('sensor.sunroom_thermostat_temperature',
'current_temperature' ) | float(0) < temp }}
actions:
- action: climate.set_temperature
target:
device_id: 56e0b45d492df3a7fadd22dcfb62151d
data:
temperature: 69
hvac_mode: heat
The problem is, at 2pm the action is triggered regardless of the current temperature. I ran the yaml through claude AI and it said:
There’s a bug in your automation — the variables defined under each trigger are not accessible in the conditions block. Trigger variables are only available within trigger-scoped contexts, not in conditions. Here’s the corrected version using a trigger.id pattern with a variables action block instead:
claude is suggesting:
> alias: Sunroom Temperature
> description: ""
> triggers:
> - trigger: time
> at: "14:00:00"
> id: "1400"
> - trigger: time
> at: "15:00:00"
> id: "1500"
> - trigger: time
> at: "16:30:00"
> id: "1630"
> variables:
> temp_threshold: >-
> {% if trigger.id == '1400' %} 45
> {% elif trigger.id == '1500' %} 55
> {% elif trigger.id == '1630' %} 65
> {% else %} 999
> {% endif %}
> conditions:
> - not:
> - condition: time
> weekday: fri
> - condition: template
> value_template: >-
> {{ state_attr('sensor.sunroom_thermostat_temperature',
> 'current_temperature') | float(0) < temp_threshold | float(999) }}
> actions:
> - action: climate.set_temperature
> target:
> device_id: 56e0b45d492df3a7fadd22dcfb62151d
> data:
> temperature: 69
> hvac_mode: heat
Thoughts?
dtrott
(David Trott)
March 17, 2026, 11:29pm
7
I would just use a “temperature ramp”
Meaning that I ramp up the temperature over time. I don’t think there is an issue turning on the heating early, if the target temperature is below the current room temperature (it won’t do anything).
You can use a variable block to calculate a target based on the time of day:
variables:
now_ts: "{{ now().timestamp() }}"
start_ts: "{{ today_at('14:00').timestamp() }}"
end_ts: "{{ today_at('17:30').timestamp() }}"
start_temp: 45.0
end_temp: 70.0
progress: "{{ (now_ts - start_ts) / (end_ts - start_ts) }}"
target_temp: "{{ (start_temp + (progress * (end_temp - start_temp))) | round(0) }}"
Then we can trigger the automation every 15 minutes:
trigger:
- platform: time_pattern
minutes: "/15"
Only execute the automation in the desired window:
condition:
- condition: template
value_template: >
{{ start_ts <= now_ts <= end_ts }}
And set the thermostat to the target temp:
actions:
- action: climate.set_temperature
target:
device_id: 56e0b45d492df3a7fadd22dcfb62151d
data:
temperature: "{{ target_temp }}"
hvac_mode: heat
You will probably need a few more conditions to hande:
Day of the week.
What to do if the heating is already on when the automation start.
… Anything else …
But that’s the basics.