Skip to content

Instantly share code, notes, and snippets.

@fredrike
Created October 2, 2023 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrike/0c8b8f6c81ce72535f9ba944ed0535f8 to your computer and use it in GitHub Desktop.
Save fredrike/0c8b8f6c81ce72535f9ba944ed0535f8 to your computer and use it in GitHub Desktop.
Blueprint to turn off a device after a random delay
blueprint:
name: Turn off after random time
domain: automation
author: Fredrik Erlandsson
input:
light:
name: Light
selector:
target:
device:
entity:
device_class:
- 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"
# {{now().isoweekday()}}
mode: single
max_exceeded: silent
variables:
dow: !input dow
delay_minutes: !input delay
trigger:
- platform: time
at: !input time
condition:
- condition: template
value_template: "{{ now().isoweekday()|string in dow }}"
action:
- delay:
minutes: "{{ range(delay_minutes) | random }}"
- service: homeassistant.turn_off
target: !input light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment