Automation with temperature sensor does not work reliable

Hi,

I’m using an automation to switch my heating on, if the temperature is below 20.8. But only inside a given time frame on specific days. This is not working reliable.

Any idea what I’m missing here?

alias: Heizung.Wohnzimmer.WE.einschalten
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.wohnzimmer
    below: 20.8
conditions:
  - condition: time
    after: "06:30:00"
    before: "21:00:00"
    weekday:
      - sat
      - sun
actions:
  - type: turn_on
    device_id: 14ea2defc2cc3cbd70b7fc9a76ae6a60
    entity_id: c9be70aaf2d2205b5056a5ad1b38efb3
    domain: switch
mode: single

This is todays data of the sensor. The automation did not start the switch:

sensor.wohnzimmer,21.17,2026-03-30T23:13:31.274Z
sensor.wohnzimmer,21.07,2026-03-30T23:57:48.397Z
sensor.wohnzimmer,21.03,2026-03-31T00:01:11.164Z
sensor.wohnzimmer,20.87,2026-03-31T00:50:01.378Z
sensor.wohnzimmer,20.77,2026-03-31T01:37:21.702Z
sensor.wohnzimmer,20.75,2026-03-31T01:44:36.510Z
sensor.wohnzimmer,20.59,2026-03-31T02:36:39.288Z
sensor.wohnzimmer,20.6,2026-03-31T02:42:43.422Z
sensor.wohnzimmer,20.49,2026-03-31T03:16:04.848Z
sensor.wohnzimmer,20.45,2026-03-31T03:36:58.241Z
sensor.wohnzimmer,20.38,2026-03-31T04:18:55.116Z
sensor.wohnzimmer,20.36,2026-03-31T04:27:51.074Z
sensor.wohnzimmer,20.13,2026-03-31T05:20:14.640Z
sensor.wohnzimmer,20.1,2026-03-31T05:50:24.408Z
sensor.wohnzimmer,20.08,2026-03-31T06:17:11.537Z
sensor.wohnzimmer,20.03,2026-03-31T06:32:32.687Z
sensor.wohnzimmer,19.93,2026-03-31T07:12:48.593Z
sensor.wohnzimmer,19.88,2026-03-31T08:02:10.877Z
sensor.wohnzimmer,19.86,2026-03-31T08:16:00.018Z
sensor.wohnzimmer,19.88,2026-03-31T08:28:38.834Z
sensor.wohnzimmer,19.94,2026-03-31T09:07:44.077Z
sensor.wohnzimmer,19.9,2026-03-31T10:01:49.191Z
sensor.wohnzimmer,19.97,2026-03-31T10:25:14.770Z
sensor.wohnzimmer,20.13,2026-03-31T10:53:12.840Z
sensor.wohnzimmer,20.25,2026-03-31T10:59:06.914Z
sensor.wohnzimmer,20.63,2026-03-31T11:37:51.904Z
sensor.wohnzimmer,20.75,2026-03-31T11:56:33.999Z

Your automation does not consider the possibility that the temperature might decrease below 20.8 before 06:30. When that happens, your automation triggers but, because the time is before 06:30, it does not execute the action.

You need to add a Time Trigger and a Numeric State Condition.

alias: Heizung.Wohnzimmer.WE.einschalten
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.wohnzimmer
    below: 20.8
  - trigger: time
    at: "06:30:01"
conditions:
  - condition: time
    after: "06:30:00"
    before: "21:00:00"
    weekday:
      - sat
      - sun
  - condition: numeric_state
    entity_id: sensor.wohnzimmer
    below: 20.8
actions:
  - type: turn_on
    device_id: 14ea2defc2cc3cbd70b7fc9a76ae6a60
    entity_id: c9be70aaf2d2205b5056a5ad1b38efb3
    domain: switch
mode: single

NOTE

An even better way to handle this situation is to use the Generic Thermostat integration. It will create a climate entity that regulates heating (or cooling).

Your automation would simply turn on the climate entity at 06:30 and turn it off at 21:00 (using Time Triggers or the Schedule integration). The climate entity takes care of the temperature regulation. This approach gives you far more flexibility, control, and convenience.

2 Likes

Your automation will have triggered at 01:37, been blocked by the condition, and then stopped.

I wonder if you want it to work 24/7 on weekdays and just in the timespan on the weekends? If so, updating Taras’ example:

alias: Heizung.Wohnzimmer.WE.einschalten
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.wohnzimmer
    below: 20.8
  - trigger: time
    at: "06:30:01"
conditions:
  - condition: or
    conditions:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: time
        after: "06:30:00"
        before: "22:30:00"
        weekday:
          - sat
          - sun
  - condition: numeric_state
    entity_id: sensor.wohnzimmer
    below: 20.8
actions:
  - type: turn_on
    device_id: 14ea2defc2cc3cbd70b7fc9a76ae6a60
    entity_id: c9be70aaf2d2205b5056a5ad1b38efb3
    domain: switch
mode: single

Many thanks. I’ve changed the automation but will also test the Generic Thermostat.

Any progress to report? Does the modified automation work better now?

Hi,

yes, I’ve seen the automation is working two days as expected!
Many thanks!
stefan

1 Like