Wth: one shot timer

Ok so you can actually do what I believe you want. But unfortunately you can’t do it in a dashboard right now.

What I believe you want is to make a script like this:

- alias: Turn a light or switch on or off at a time
  mode: parallel
  fields:
    devices:
      name: Devices
      description: List of lights or switches to turn on or off
      example: switch.heater
      selector:
        entity:
          domain:
            - light
            - switch
          multiple: true
    turn_on:
      name: Turn on
      description: True to turn on, false to turn off
      default: true
      example: true
      selector:
        boolean:
    time:
      name: Time
      description: Will turn the switches on or off at the specified time
      example: "05:00:00"
      selector:
        time:
  sequence:
    - alias: Wait until the specified time
      wait_template: "{{ now() >= today_at(time) }}"
    - alias: Turn the things on or off
      service: "homeassistant.turn_{{ 'on' if turn_on else 'off' }}"
      data:
        entity_id: "{{ devices }}"

Because if you make this script and then go to Developer tools → Scripts to run it I think you’ll see its exactly what you’re looking for:

Other then the “go to yaml mode” what you’re looking for right? Select the devices, choose on or off, pick a time and run it, it’ll turn them on or off at the time you picked. Anyone could use this if it was on a dashboard. Can use this same script as many times as you want with different tasks and times and each run just does one thing.

If you’re like me this all sounds great. Until you realize the only place you can see a script like this is in developer tools. If you put this script in a dashboard all you get is a “run script” button with no parameter entry. Useless :angry:

This was my own WTH moment a while ago that I forgot about until you reminded me just now. If you also want this now, feel free to vote for it:

2 Likes