Schedule using helpers

I want to use a schedule to trigger my wake up conditions. Because of various issues I have a different wake up time every day. The scheduer is okay, but I either have to edit the YAML or go to the helper and edit the schedule. I would like to be able to do it from the dashboard by using helpers. (If there is a different / better way to achieve this I am open to it.

An example of the sort of thing I want to do is below, but the configuration.yaml won’t accept it.

schedule:
  wakeup_schedule:
    name: "Wake Up schedule"
    monday:
      - from: input_datetime.simon_wake_up_mon
        to: "11:00:00"
    tuesday:
      - from: input_datetime.simon_wake_up_tue
        to: "11:00:00"
    wednesday:
      - from: input_datetime.simon_wake_up_wed
        to: "11:00:00"
    thursday:
      - from: input_datetime.simon_wake_up_thr
        to: "11:00:00"
    friday:
      - from: input_datetime.simon_wake_up_fri
        to: "11:00:00"
    saturday:
      - from: input_datetime.simon_wake_up_sat
        to: "11:00:00"
    sunday:
      - from: input_datetime.simon_wake_up_sun
        to: "11:00:00"

I will just use it as a trigger in the “Wake Up” automation.

Why not just use the Input Datetime helpers in a Time Trigger to wake you up?

You can just use your Input datetime helpers in a time trigger with a template condition to check the day of the week matches:

trigger:
  - platform: time
    at:
      - input_datetime.simon_wake_up_mon
      - input_datetime.simon_wake_up_tue
      - input_datetime.simon_wake_up_wed
      - input_datetime.simon_wake_up_thr
      - input_datetime.simon_wake_up_fri
      - input_datetime.simon_wake_up_sat
      - input_datetime.simon_wake_up_sun
condition:
  - "{{ (trigger.entity_id).split('_')[-1] == now().strftime('%a')|lower }}"

You will want to set the automation mode to parallel or queued to make sure today’s time event isn’t blocked by a different day’s time coinciding.

1 Like

Thanks, worked perfectly and I learned something about python!

Also I couldn’t find a list of abreviations, is Thursday ‘thr’?

Thursday will be thu

1 Like

When I asked you this:

Why not just use the Input Datetime helpers in a Time Trigger to wake you up?

You didn’t respond.

Had you replied “OK”, my suggestion would have been to rename each Input Datetime’s entity_id as shown below in order to have a simple condition.

alias: example
trigger:
  - platform: time
    at:
      - input_datetime.simon_wake_up_1
      - input_datetime.simon_wake_up_2
      - input_datetime.simon_wake_up_3
      - input_datetime.simon_wake_up_4
      - input_datetime.simon_wake_up_5
      - input_datetime.simon_wake_up_6
      - input_datetime.simon_wake_up_7
condition:
  - "{{ trigger.entity_id[-1] | int(0) == now().isoweekday() }}"
action:
  .. etc ...

On a separate but related note, why didn’t you create the Schedule via the UI? It would allow you to change the wake up time visually.

1 Like

Thanks, sorry, when I checked back I saw the other solution. Yours is quite neat though.

A quick additional question, if I want the wake up sequence to start 1 minute before is there some easy way to use timedelta (or other method)?

On your second question, I didn’t like that the schedule had a duration, so the solutions here look better, but also I wanted times not to the nearest half hour, and I couldn’t see how to edit the schedule down to the minute.

You would have to use a Template Trigger because a Time Trigger doesn’t (currently) support an offset.

1 Like