I have an issue with rules running more than once - specifically, rules based on cron jobs. Rules based on device changes seem to work fine.
I’ve researched, and I think what I’m seeing is related to the bug: https://github.com/openhab/openhab2-addons/issues/1949 However, my issue isn’t that I’m triggering on multiple events. I’m only triggering on one cron job, but I’m seeing multiple instances in the logs.
I’ve also read Possible bug: rules fire more then once I’m using Notepad++ for editing, so I don’t think the temp file issue is at play here. I am seeing the multiple instances of a file in the logs when I save an update (not my primary issue here, but I figured I’d mention it for clarity):
2017-04-13 22:06:16.844 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'notification.rules'
2017-04-13 22:06:16.904 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'notification.rules'
The rule that I started noticing this on was one to monitor whether communications had been lost between OH2 and my Veras. In trying to troubleshoot, I removed all my other rules in the system, and then paired this one down to a very slim version for testing:
rule "Vera Communication Monitor"
when Time cron "0 /10 * * * ?"
then
logInfo(" Notifications - Communications", "!!!!!! Vera Communication Status - Testing..."
logInfo(" Notifications - Communications", "!!!!!! Vera Communication Status - Current: " + VeraHouseTime.state + " Last: " + VeraHouseTimeLast.state)
VeraHouseTimeLast.postUpdate( VeraHouseTime.state )
VeraShopTimeLast.postUpdate( VeraShopTime.state )
end
And here’s what I got in the log after a reboot of the server:
2017-04-13 22:20:02.740 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Testing...
2017-04-13 22:20:02.740 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Testing...
2017-04-13 22:20:02.743 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Current: 2017-04-13 22:19:53 N Last: NULL
2017-04-13 22:20:02.743 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Current: 2017-04-13 22:19:53 N Last: NULL
And at the next instance of it running:
2017-04-13 22:30:00.002 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Testing...
2017-04-13 22:30:00.002 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Testing...
2017-04-13 22:30:00.004 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Current: 2017-04-13 22:30:00 N Last: 2017-04-13 22:19:53 N
2017-04-13 22:30:00.006 [INFO ] [ Notifications - Communications] - !!!!!! Vera Communication Status - Current: 2017-04-13 22:30:00 N Last: 2017-04-13 22:30:00 N
At this point, I have no rules but this one, so I decided to remove this rule as well - I couldn’t think of anything else that might be better to try. Restarted the server, and I see I’m still getting duplicates in the log for my astro devices at startup (there should be two suns - one regular, one offset, and a moon).
2017-04-13 23:04:23.423 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-sun at midnight for thing astro:sun:0451ef7e
2017-04-13 23:04:23.423 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-moon at midnight for thing astro:moon:b3d70a42
2017-04-13 23:04:23.425 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-positional with interval of 300 seconds for thing astro:moon:b3d70a42
2017-04-13 23:04:23.426 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-sun at midnight for thing astro:sun:offset
2017-04-13 23:04:23.426 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-positional with interval of 300 seconds for thing astro:sun:0451ef7e
2017-04-13 23:04:23.427 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-sun at midnight for thing astro:sun:0451ef7e
2017-04-13 23:04:23.429 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-positional with interval of 300 seconds for thing astro:sun:0451ef7e
2017-04-13 23:04:26.353 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:moon:b3d70a42
2017-04-13 23:04:26.908 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:sun:offset
2017-04-13 23:04:26.908 [INFO ] [.astro.internal.job.AbstractDailyJob] - Scheduled astro event-jobs for thing astro:sun:0451ef7e
As you can see, it tries to do two instances of thing astro:sun:0451ef7e. I looked back through the logs, it’s been there all along (different ones duplicate, and I’ve seen up to 3 instances of a device in the log). I don’t think it’s caused an issue, but I’m only turning lights on/off based on these events at this point, so duplication shouldn’t hurt anything…
I’m assuming that the astro devices are ran off of cron as well. If so, then it would definitely point to there being some issue with cron rules running multiple times.
I’m thinking my next step in this would be to remove all my astro things. Before I do that, I figured I’d get some feedback as I’m definitely no expert in OH2, or Linux…
Thoughts?..
Thanks,
Danny