I have astro items and rules set up to turn on a switch at dawn (first at dawn, then again at sunrise just in case), and set to turn off a switch at civil dusk then nautical dusk…
…and it works great! Except that every once in a while (say on the order of once every two weeks) neither of the night time events fires at all. (So my rules think it’s daytime when it’s dark out.)
How would I go about debugging this? I already have loginfo lines for when my rules get called by astro, and they’re present every day like clockwork except the day that it doesn’t work (today). The dawn & sunrise events are there, but neither of the dusk and nautical dusk events are in the log.
Here are my item definitions just in case I messed up something obvious:
Switch VIRTUAL_DARK_SWITCH "Virtual DARK switch that turns on at dusk, off at dawn." (Group_Virtual, Group_Persistence)
Switch VIRTUAL_NDAWN_SWITCH "Virtual switch that pulses on at the start of nautical dawn." {astro="planet=sun,type=nauticDawn,property=start"} // we need this as a trigger, so that we know nautical dawn just happened
Switch VIRTUAL_DAWN_SWITCH "Virtual switch that pulses on at the start of dawn." {astro="planet=sun,type=civilDawn,property=start"} // we need this as a trigger, so that we know dawn just happened
Switch VIRTUAL_DUSK_SWITCH "Virtual switch that pulses on at the start of dusk." {astro="planet=sun,type=civilDusk,property=start"} // we need this as a trigger, so that we know dusk just happened
Switch VIRTUAL_NDUSK_SWITCH "Virtual switch that pulses on at the start of nautical dusk." {astro="planet=sun,type=nauticDusk,property=start"} // we need this as a trigger, so that we know nautical dusk just happened
Switch VIRTUAL_SUNRISE_SWITCH "Virtual switch that pulses on at sunrise." {astro="planet=sun,type=rise, property=start"} // again, trigger to know when sunrise just happened
Switch VIRTUAL_SUNSET_SWITCH "Virtual switch that pulses on at sunset." {astro="planet=sun,type=set, property=start"} // again, trigger to know when sunrise just happened
And my corresponding rules…
rule "Update dark switch state dusk dawn"
when
Item VIRTUAL_DUSK_SWITCH changed to ON or
Item VIRTUAL_DAWN_SWITCH changed to ON
then
{
logInfo("openhab","Update dark switch (dusk, dawn)")
// (do more stuff omitted)
}
end
rule "Update dark switch state - sunrise n.dusk"
when
Item VIRTUAL_SUNRISE_SWITCH changed to ON or
Item VIRTUAL_NDUSK_SWITCH changed to ON // nautic dusk
then
{
// this is a second chance to set the virtual dark switch correctly before it really matters. (i.e. before it get REALLY dark or REALLY light!)
// if everything is working correctly, when the sun rises the virtual dark switch should already be off by the time sunrise hits (since dawn happens beforehand and should have already turned it off).
// but I wrote this just in case. Occasionally the virtual dark switch won't fire off and haven't figured out why yet, so doing a second pass at it as a troubleshooting step.
logInfo("openhab","Update dark switch (sunrise, n.dusk)")
// (do more stuff omitted)
}
end
Any suggestions (on either what I’m doing wrong or the best way to go about debugging this) are appreciated in advance!