#Switching the lights off between 22:15-22:45 at a random time.

1 messages · Page 1 of 1 (latest)

radiant stump
#

Hi all,

I am heading on holiday soon. I want to have my lights on at home so it looks like I am at home. Since I usually go to sleep between 22:15-22:45 I would like to have the lights switched off at random times during that time frame daily. Currently I've it set at 22:30 by default every day.
How can I program it switches off at random times during the above mentioned timeframe?

Here's my current YAML code:

alias: 4 - Sunset Daily Off [22:30]
description: ""
triggers:
  - trigger: time
    at: "22:30:00"
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      device_id:
        - 03c454a81d6ec9f0e9cc9881a9304543
        - a2df7ca9f5971c7137ea88d8b6cee072
        - f430ec6f669be798c74e0eb341d2ada9
        - a211a51ef75a082e580e64f9a5dff748
        - 2d926ba4642e9706a4fd39ca3be0d76f
        - 7a1aef0b0c631475c84bf45894a0b772
        - e94da7c20cdd44fcb2216c07139d1abb
mode: single

Thank you for your reply and help. 🙂

wooden sinew
#

do they all need to be switched off at the same time, or all different times?

radiant stump
#

Best would be all at the same time as they do now.

wooden sinew
#

Okay, that's also easiest

#

trigger at 22:15 and add a random delay of 0-30 minutes

#
alias: "4 - Sunset Daily Off [22:15 - 22:45]"
description: ""
triggers:
  - trigger: time
    at: "22:15:00"
actions:
  - delay:
      minutes: "{{ range(0, 31) | random }}"
  - action: light.turn_off
    target:
      device_id:
        - 03c454a81d6ec9f0e9cc9881a9304543
        - a2df7ca9f5971c7137ea88d8b6cee072
        - f430ec6f669be798c74e0eb341d2ada9
        - a211a51ef75a082e580e64f9a5dff748
        - 2d926ba4642e9706a4fd39ca3be0d76f
        - 7a1aef0b0c631475c84bf45894a0b772
        - e94da7c20cdd44fcb2216c07139d1abb
mode: single
#

you can also make it 0 - 1800 seconds for more randomness

#
  - delay:
      seconds: "{{ range(0, 1801) | random }}"
radiant stump
#

Amazing, thank you so much. I will give it a try tonight. 🙂