Fighting and losing to Time condition

I’m trying to automate some space heaters. If it’s after 20:30 and the room is under 72 turn on. The temperature is easy the time condition is driving me nuts.

alias: Master Bedroom cold
description: ''
trigger:
  - platform: time_pattern
    minutes: '5'
condition:
  - condition: time
    after: '20:30:00'
    before: '08:00:00'
  - condition: numeric_state
    entity_id: sensor.master_bedroom_temperature
    below: '72'
action:
  - type: turn_on
    device_id: 32878c293201bd925feca01c1dab60ea
    entity_id: switch.master_bedroom_heater_0bb71325_on_off
    domain: switch
mode: single

There is no need for a time pattern trigger in this case… there are cases where it is appropriate, but otherwise it is a very inefficient way to trigger an automation.

alias: Master Bedroom cold
description: ''
trigger:
  - platform: time
    at: '20:30:00'
  - platform: numeric_state
    entity_id: sensor.master_bedroom_temperature
    below: '72'
  - platform: homeassistant
    event: restart
condition:
  - condition: time
    after: '20:30:00'
    before: '08:00:00'
  - condition: numeric_state
    entity_id: sensor.master_bedroom_temperature
    below: '72'
action:
  - type: turn_on
    device_id: 32878c293201bd925feca01c1dab60ea
    entity_id: switch.master_bedroom_heater_0bb71325_on_off
    domain: switch
mode: single

Thanks, I’m really having problems with the time condition. I was getting inconsistent results just triggering off numeric_state.

@Didgeridrew solved your issue I guess, so just for the record. Your pattern triggers every hour at 5 minutes past the hour. If you want to trigger it every 5 minutes (which I think you are aiming for), you should use:

trigger:
  - platform: time_pattern
    minutes: '/5'

instead of

trigger:
  - platform: time_pattern
    minutes: '5'

Thanks, I didn’t know that about time_pattern. My real problem is that the time condition was not triggering but it’s posable that me not understanding time pattern was the problem.

Triggers and conditions are not the same thing. Conditions do not trigger anything.

What he said :point_up_2: :slightly_smiling_face:
Next to that, it’s very likely that your automation did trigger at 5 past the hour, but that the condition didn’t match. If I am not mistaking, the last triggered isn’t updated if the conditions do not match. Traces, like it’s called since the last release, is your friend here. It shows you the last 5 times it triggered and everything afterwards.

A good starting point is to pay a visit to the docs in case you try something new. HA can do a lot, so even after the years I still pay a visit to check the correct syntax from time to time. You learn al the time and ones creativity is more often the limitation than HA is, so no worries :smiley: