Greater than 60-Minute Offset from Sunrise/Sunset?

I’m trying to migrate away from Smart lighting, but I have several routines that turn on lights 90 minutes BEFORE sunset. Other than installing a 3rd party calendar control, has anyone figured out a way to make this work using a standard ST routine?

Looks like 60 minutes before/after is the max setting for adjusting the time for sunrise or sunset in routines.

You are limited by the constraints of the mobile app UI unfortunately. You may be able to use the Rules API to have bigger offsets. You can probably also use the 3rd party rules engine to get bigger offsets, however, those routines execute from their cloud, not locally.

1 Like

It’s been awhile since I used it, but I came up with a way to do this. I created a virtual switch first, and then a routine that turned on the switch at 60 minutes before sunset. The switch has an option to delay turning on/off for a selectable amount of time, so I chose 30 minutes. Not super elegant, but it works.

As described, won’t that turn on the switch 30 minutes before sunset? Not 90 minutes?

You could use that method for a routine that would turn the switch off 90 minutes after sunset. Or after sunrise. But the delay doesn’t change the hour when the timer starts, does it?

So at 60 minutes before sunset, the routine would be activated, but then it would delay for 30 minutes before actually turning the light on. Thus turning on at 30 minutes before sunset.

Or am I confused?

1 Like

It made sense in my head. :grinning: But, yeah, that’s backwards.

I did have it working correctly, although in my case it was 2 hours before sunset because our living room faces east and it gets dark in there early. I removed it a long time ago, so I’m going by memory and obviously that’s failing me.

1 Like

I am using @Mariano_Colmenarejo virtual calendar driver and I turn on a switch 3 hours before sunset. You can turn on and turn off any number of hours / min before or after sunset, works perfectly in ST routines and have had no issue till date.


Thanks. What conditions do you use in his VC to actually identify 3 hours before sunset?

It’s actually 3.5 hours before sunset. Just remember to set the local UTC offset for your region in the VC settings. Also, I checked the UTC offset in the precondition to see if it’s BST or BWT (I live in the UK and needed this for some other purpose) but you may not need to.