Trigger automation only between certain hours

Hello!!

Is it possible to tell Hass.io to trigger an action only between certain hours of the day?

For example:

  • alias: Set AC to 76
    trigger:
    platform: state
    entity_id: binary_sensor.door_sensor
    from: “on”
    to: “off”
    range_time: from(09:00) to (19:00)

Note that “range_time” is something I made up for the example.

Thanks !!!

You can use condition(s), before or after ‘action:’

condition:
condition: time
after: ‘09:00:00’
before: ‘19:00:00’

And second section on page below:

3 Likes

So how do you make the range cross over midnight like 20:00:00 to 6:00:00. I see commands like before: and after: but I think either I’m confused or Hassio is confused as to what that means.
What I really want to do is determine if my garage door is open for more than 10 minutes during the night, notify me and also close it. I have the notify and close working, just the trigger and conditions don’t seem to work as expected. Running hassio 88.1.

Listed under the time condition in the docs.

verbatim:

“Time condition windows can span across the midnight threshold. In the example above, the condition window is from 3pm to 2am.”

1 Like

Thanks Petro
When I originally did this, it never triggered and I thought I was doing something wrong. Since the automation appears to be working with only the ‘after’:

condition:
condition: and
conditions:
- condition: time
  after: '21:00:00'
- condition: state
  entity_id: switch.garage_door
  state: 'on'

I’ll put in the ‘before’ again and try it. Maybe it was something else that didn’t work in the automation. Automations are hard to debug - it would be nice to be able to step through them and watch the conditions get met or not. Even a automation log to see what happened after the fact would be great. The only problem I see is that it would have to trigger to get the log entry.

Cheers.