Dynamic time trigger?

Hi is it possible to have a dynamic time trigger? So that it can differ every day?
I want the lights to go out at a different time each day. so that it looks more realistic that someone is home. when we are on vacation, for example.

I want to avoid having an automation for every day.
Thanks!

I’ve used this to good effect:

I use this template on my lights - trigger every hour (when its dark)

delay: 00:{{ range(15, 40)|random }}:00

Most people are creatures of habit… lights turning on and off at random looks weird and obviously fake to anyone paying actual attention.

How does this looks like in the automation yaml?
“Trigger” every hour and at “Condition” the line you mentioned?

and how to read it? range between 15 and 40 minutes right?
Thanks :slight_smile:

Yes random mintues 15-40

alias: "Alarm : Toggle spot"
description: ""
trigger:
  - platform: time_pattern
    minutes: /50
    id: tænd
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: tænd
          - type: is_illuminance
            condition: device
            device_id: eec81c0a12a311ebb950218106acc069
            entity_id: sensor.lyssensor
            domain: sensor
            below: 2
        sequence:
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.stue_1438814
          - delay: 00:{{ range(15, 40)|random }}:00
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.stue_1438814
    default: []
mode: restart
1 Like