Note that these errors will not stop the rule working later, they only affect the router-offline-at-openhab-bootup situation.
Above assembled from different logs.
I can propose the theory of events.
Note that it takes five minutes to fire the rule from the trigger event. This is a system under stress. Not surprising at bootup time, but it exposes timing cracks we might normally never fall down.
Okay, so the rule is running, next we do a createTimer
- it’s birthday is embedded in message 3, the jobname. Again, it’s taken a whole second to get two lines along in the rule.
What’s not obvious is that createTimer is partly asynchronous, the creation part completes before the handle is written back to the variable.
Next, the timer goes off after 1 second - first thing it should do is log out it’s own handle. But the rule thread is still mired in treacle and hasn’t yet finished updating the handle variable (maybe partly because the timer code is using it). The timer code blows up, which deletes the handle.
Now the rule can finish updating the handle - but by now it’s invalid, the last message in that set.
Alright, so in summary it’s a nasty timing race with two root causes - extended processing times during bootup, and timer code referencing its own handle shortly after creation. Spiteful little bug.
One circumvention would be a much longer first run time for the timer - say 10+ secs. Simple enough, but does not address -
On reflection, I’d comment that relying on the rule detecting the change to OFF at bootup time is bad practice anyway. If the network binding sets Item states before rules come online (which is actually desireable!) your ‘changed’ rule will never trigger at boot time.
If network binding were a bit slower, we’d never run into this issue. This pot-luck approach is no good, run the same code on a different box for different results.
Let’s change that.
@Andrew_Rowe suggests the “delay rule” process.
I’m not sure that is the whole answer, because the rule currently fires from ‘changed’. You need something else to see if it is already offline at bootup.