Trigger automation when current time is bigger than X

Hi,

I have water boiler and two date_time entities: start heating and stop heating.
If my start heating is set to 11 AM and automation is enabled during this time, then exactly at 11 AM water boiler is heating.

I’d like to stop automation from time to time. I’ve added entity which is controlling if automatic heating should be working or not.

I don’t know how to solve such scenario:

  1. automation is disabled
  2. start heating is set to 11 AM
  3. at 1 PM I realized that automation was disabled so I enabled it again
  4. automation should enable heating as it’s after 11 AM. Currently it’s not starting heating during this day, it will start next days at 11 AM.

You could add another trigger to your automation for the state of the automation, something like this:

...
  trigger:
    - platform: state
      entity_id: automation.your_automation
      from: off
      to: on
    - platform: time 
      at: "11:00:00"
  condition:
    - condition: time 
      after: "11:00:00"
      before: "23:00:00"
....

So this will start at 11 AM if the automation is on, and if you turn the automation back on between 11AM and 11PM.

Why was the automation disabled?

Was it disabled by mistake or does some other automation occasionally disable it?

Sometimes I don’t want to have automatic water heating, for example when I’m on vacation.

The common practice is to add a condition to the automation that checks the state of an input_boolean (or other entity). For example, if you have an input_boolean representing vacation mode, the condition checks if the input_boolean is off. If it’s on then the condition prevents the automation from executing its actions.

This technique permits the automation to autonomously determine when it should or shouldn’t perform its actions. This allows the act of disabling the automation to be reserved for special situations where the automation is, say, misbehaving and needs to be ‘taken offline’ until you have time to investigate the cause of the problem. Or if you create a new version of the automation, you can disable the old version and ‘keep it in reserve’ in case the new version has problems.

1 Like