08-12-2024 10:45 AM
I need help creating a routine script. I wrote something like the one below, but unfortunately, it doesn't work correctly. The light turns on, but it ignores the time condition. I want the light to turn on when I return home, 7 days a week, but only during the time period between 30 minutes before sunset and 30 minutes after sunrise.
My script:
metadata:
name: Lights turn on
description: Lights turn on when any home member is back home
automations:
- starters:
- type: home.state.HomePresence
state: homePresenceMode
is: HOME
condition:
type: time.between
after: SUNRISE-30min
before: SUNSET+30min
actions:
- type: device.command.OnOff
devices:
- LEDY - Salon
- Lampa pod TV - Salon
on: true
Answered! Go to the Recommended Answer.
08-12-2024 11:18 AM - edited 08-12-2024 11:19 AM
It looks like you have your sunset and sunrise backwards. The way you have it written, it will only trigger from 30min after sunrise until 30 min before sunset.
Try this instead.
type: time.between
after: SUNSET-30min
before: SUNRISE+30min
08-12-2024 11:18 AM - edited 08-12-2024 11:19 AM
It looks like you have your sunset and sunrise backwards. The way you have it written, it will only trigger from 30min after sunrise until 30 min before sunset.
Try this instead.
type: time.between
after: SUNSET-30min
before: SUNRISE+30min
08-12-2024 11:59 PM
Thanks a lot! you're right 🙂