cancel
Showing results for 
Search instead for 
Did you mean: 

Lights turn on when any home member is back home (30 min before sunset and 30 min after sunrise)

Arkadiusz1
Community Member

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

 

1 Recommended Answer

GBD
Community Member

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

View Recommended Answer in original post

2 REPLIES 2

GBD
Community Member

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

Arkadiusz1
Community Member

Thanks a lot! you're right 🙂