Well I’m stumped! I have been running openHAB 2.1 for about 3 months now and in the last couple weeks I have made some rules that use cron triggers. For the life of me I cannot get them to work, nor can I find anything online on in these forums to help me.
I am working with several rules that fire once a minute, some of which also fire when sensor inputs receive updates. The ‘received update’ triggers are working fine.
I have found older posts of people with issues of identical cron triggers on multiple rules not working, so I tried switching each one to a different second. That did not work.
I have found older posts of people with issues having multiple cron triggers in the rule, but I am only using one cron trigger in each rule. I also tried commenting out the other triggers and using only the cron trigger, to no avail.
I have turned on logging for the rule engine and can see it register each and every one of my cron triggers at startup, and every time I save a rules file. Most of the rules will run once, sometimes twice, via the cron trigger after a restart, but not all of them. Yet all of the astro binding cron events run normally (perhaps because the are outside the rule engine?)
Here is the simplest of the rules, copied directly from my rules file. When the setpoint ‘offsets’ are changed, the rule fires, and once when the system is restarted the cron trigger fires, but never again.
rule "Viv Lighting Automation"
when
//System started or
//Item light_viv_sunrise_offset changed or
//Item light_viv_sunset_offset changed or
Time cron "4 * * * * ? *"
then
logInfo("MIKE", "DEBUG - viv lighting automation running")
// updates the commanded state for the lights based on current time,
// sunrise/sunset time, and sunrise/sunset offset
// guard against multiple concurrent runs
viv_light_automation_lock.lock()
try {
// pull in settings from items
val on_time = new DateTime((astro_sun_rise_start.state as DateTimeType).calendar.timeInMillis + ((light_viv_sunrise_offset.state as DecimalType).longValue * 60 * 1000))
light_viv_turn_on_time.postUpdate(on_time.toString)
val off_time = new DateTime((astro_sun_set_start.state as DateTimeType).calendar.timeInMillis + ((light_viv_sunset_offset.state as DecimalType).longValue * 60 * 1000))
light_viv_turn_off_time.postUpdate(off_time.toString)
// compare current time to sunrise and sunset, including offsets
if(now.isAfter(off_time)) { // past sunset turn off time
light_viv_commanded.postUpdate(OFF)
} else {
if(now.isAfter(on_time)) { // past sunrise turn on time
light_viv_commanded.postUpdate(ON)
} else { // before sunrise turn on time
light_viv_commanded.postUpdate(OFF)
}}
} finally { viv_light_automation_lock.unlock() }
end
If you could point me in the right direction, an idea of where to look, anything would be helpful at this point.
Thanks,
Mike