Hi all,
Due to irregular work times and being prone to low energy during short daylight-season (aka fall & winter), I’d like to turn on and off some lights in relation to noon in the day. If I use clocks, it shifts once a year, while switching in relation to noon should provide a more gentle slope into and out of daylight savings time. I noticed my tropical houseplants (banana, mango) go into a growspurt at about 14 hours daytime, so I decided on that after I found out it is exactly 420 minutes from noon either way. Once I get it working I’ll probably tweak it to give me 16 hours of light a day.
I have read up on the astro binding, and I think I understand. I need to set start and end times for eventRanges to trigger rules. I should not need to define
Thing astro:sun:offset "Fake Sun" @ "Home"[ geolocation="anonymized moehahah", interval=60, useMeteorologicalSeason="true" ] {
Channels:
// event offset
Type rangeEvent : rise#event [
offset=60
]
// Noon
// dateTime offset
Type start : noon#start [
offset=-420
]
Type end : noon#end [
offset=420
]
Type rangeEvent : noon#start [
offset=-420
]
Type rangeEvent : noon#end [
offset=420
]
// event offset
Type rangeEvent : set#event [
offset=-60
]
}
And after restarting openhab, I can confirm this changes the event start and end times in the openhab.log.
So we’re all good, right?
sort of. If I don’t set the dateTime offset for noon,
// dateTime offset
Type start : noon#start [
offset=-420
]
Type end : noon#end [
offset=420
]
then the notice saying it’s 420 minutes prior to noon / noon was 420 minutes ago, appears in the logs, AT NOON! not at 420 minutes before or after noon, at noon start, and a minute later at noon end.
So this is why I set a datetime offset.
rule "Switch On Before Sunrise"
when
Channel "astro:sun:offset:noon#event" triggered START
then
logInfo("Astro","Noon starts in 420 minutes")
Outlet43_Power.sendCommand(ON)
end
rule "Switch Off After Sunrise"
when
Channel "astro:sun:offset:rise#event" triggered START
then
logInfo("Astro","Sunrise ended an hour ago")
Outlet43_Power.sendCommand(OFF)
end
rule "Switch On Before Sunset"
when
Channel "astro:sun:offset:set#event" triggered START
then
logInfo("Astro","Sunset starts in 60 minutes")
Outlet43_Power.sendCommand(ON)
end
rule "Switch Off After Sunset"
when
Channel "astro:sun:offset:noon#event" triggered END
then
logInfo("Astro","it's 420 minutes after noon")
Outlet43_Power.sendCommand(OFF)
end
So, I would expect, from these rules, to have noon offset start at 420 minutes prior to noon, turning the light on. Then, an hour after sunrise, the light turns off again.
Then, an hour before sunset, the light turns on, after which it waits until 420 minutes have passed, and turns off the light again.
However: I guess the light turned on at noon, since it was on when I got home from work at about 18:30. It was supposed to turn on at about 17:45, because sunset is at 18:45. So I waited. But the moment 420 minutes after noon had passed, came, and went.
The light was still on, until I went to the bathroom at midnight, after which I noticed it being off.
When I came back, the logs showed this (I grepped for astro events)
2021-10-07 00:00:30.241 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:offset:morningNight#event triggered START
2021-10-07 00:00:30.429 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:morningNight#event triggered START
I don’t know what morningNight is, but it turned off the light and I don’t see it anywhere in my rules, things, or items.
This seems like an inconsistency caused by a typo/oversight on the developers side.
Please point out if I have, myself, had an oversight. It is entirely possible. I still consider myself a noob, although I must admit I am more experienced than I was 10 years ago. Slowely but surely, I’ll turn into an intermediate programmer