Skip to content

Instantly share code, notes, and snippets.

@fredrike
Last active August 26, 2025 16:12
Show Gist options
  • Select an option

  • Save fredrike/a4b9fd6c139a766b548ed0b0bed75261 to your computer and use it in GitHub Desktop.

Select an option

Save fredrike/a4b9fd6c139a766b548ed0b0bed75261 to your computer and use it in GitHub Desktop.
Blueprint to turn on a device after a random delay
blueprint:
name: Turn on after random time
domain: automation
author: Fredrik Erlandsson
source_url: https://gist.githubusercontent.com/fredrike/a4b9fd6c139a766b548ed0b0bed75261/raw/69eff403bd25222c247dde6c2038b579054192da/on_delay.yaml
input:
light:
name: Light
selector:
entity:
domain:
- light
- switch
time:
name: Time
selector:
time:
delay:
name: Delay
default: 0
selector:
number:
min: 0
max: 30
unit_of_measurement: minutes
dow:
name: Weekday(s)
default: ["0", "1", "2", "3", "4", "5", "6"]
selector:
select:
multiple: true
mode: list
options:
- label: Mon
value: "1"
- label: Tue
value: "2"
- label: Wed
value: "3"
- label: Thu
value: "4"
- label: Fri
value: "5"
- label: Sat
value: "6"
- label: Sun
value: "0"
before_sun_rise:
name: Before sunrise
description: Ensure that sun have not risen
default: true
selector:
boolean:
mode: single
max_exceeded: silent
variables:
dow: !input dow
delay_minutes: !input delay
before_sun_rise: !input before_sun_rise
trigger:
- platform: time
at: !input time
condition:
- condition: template
value_template: "{{ now().isoweekday()|string in dow }}"
- condition: or
conditions:
- condition: template
value_template: "{{ before_sun_rise }}"
- condition: sun
before: sunrise
action:
- delay:
minutes: "{{ range(delay_minutes) | random }}"
- service: homeassistant.turn_on
target: !input light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment