Time condition never triggers on it's own

Hi, I’m having an issue with one of my automation:
I wasn’t able to make this fire automatically but after I manually trigger the automation, it continues to run until the end time.
Example: It doesn’t fire after 19:00 even if the temp is well below 21.5 but if I manually trigger the action, it continues to trigger every time the temp goes under 21.5.
(This automation goes along with one that turns the heater off at 22.5)

I have 3 different sensors in the room and none of them trigger the heater.

alias: Bar room heater - On (21.5)
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.bar_th16_temp
    below: '21.5'
  - platform: numeric_state
    entity_id: sensor.lumi_bar_s_room_temperature
    below: '21.5'
  - platform: numeric_state
    entity_id: sensor.sonoff_barheater_si7021_temperature
    below: '21.5'
condition:
  - condition: or
    conditions:
      - condition: time
        after: '11:00:00'
        before: '15:00:00'
      - condition: time
        after: '19:00:00'
        before: '07:30:00'
action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.bar_room_heater
mode: single

It won’t if the temperature fell below 21.5 prior to 19:00.

A Numeric State Trigger will trigger when the value crosses the threshold. After the value has crossed the threshold there is no further triggering (the trigger is now “set”). To “reset” it, the value must first rise above the threshold if using below, or fall below the threshold if using above (it’s also reset after Reload Automations or restarting Home Assistant).

In your automation, if the first sensor falls below 21.5 but the current time doesn’t fall within the two time ranges, the action will not be executed. If the sensor now remains below 21.5 when the current time does fall within the time range, the action will not be executed. Why? Because the trigger only occurs when the sensor’s temperature crosses the threshold of 21.5 and not anytime afterwards if the temperature continues to decrease (or simply remain below the threshold of 21.5).

BTW, when you manually trigger an automation, it skips the trigger and condition and simply executes the action (i.e. it behaves like a script).


NOTE

The solution is to add a Time Trigger:

  - platform: time
    at:
      - '11:01:00'
      - '19:01:00'

and a condition to check the temperature sensors:

  - condition: template
    value_template: >
      {{ states('sensor.bar_th16_temp')|float < 21.5 or
         states('sensor.lumi_bar_s_room_temperature')|float < 21.5 or
         states('sensor.sonoff_barheater_si7021_temperature')|float < 21.5 }}

This covers the situation where a temperature sensor fall below the threshold prior to one of the two time periods.

1 Like

Thank you very much. That did it

1 Like