@ldaniel, a timer like that works well for a positive offset but not for a negative offset. I live in the mountains so it remains dark and gets dark considerably after sunrise and before sunset so negative offsets are pretty useful to me.
That got me to thinking and I believe you can handle the generic case (positive and negative offsets) through a very similar rule as well by triggering at System started, midnight, and when the offset changes and calculating the next time the timer should go off rather than setting a timer after the sunset event occurs. We have to do some book keeping though to cancel any previous timer when the offset is changed.
Here is some pseudo-rule code
val sunriseTimer = null
rule "Set Sunrise Timer"
System started or
Time cron "0 0 0 * * * ?" or
if(sunriseTimer != null) sunriseTimer.cancel
var timeToClose = // Generate a DateTime for the next sunrise + Sunrise_Offset
sunriseTimer = createTimer(timeToClose) [|
// do stuff
sunriseTimer = null
I always have a hard time working with datetime in OH so I’ll leave the calculation as an exercise for the student.