Hi there!
Currently I’m looking for errors in my openhab.log to track down anything which does not belong there – for eliminating another problem.
I see errors like
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Determine number of activated lights': null
during regular operation.
Here’s my rule which is causing this behavior. I use this rules to prepare charting of active light counts (afaik there’s no way to get a Group:Switch into a chart).
import org.eclipse.xtext.xbase.lib.Functions
val Functions$Function2<GroupItem, GroupItem, Boolean> updateNumberItem= [ groupItem, associationGroup |
val groupItemName = groupItem.name
logInfo("counters", "updateNumberItem=" + groupItemName)
val numberItemName = "I" + groupItemName.substring(1)
val numberItem = associationGroup.members.findFirst[ ni | ni.name == numberItemName ]
var count = groupItem.allMembers.filter(l|(l.state > 0 || l.state==ON)).size
logInfo("counters", "update to " + numberItem.name + " for group " + groupItem.name + ": " + count)
numberItem.postUpdate(count)
true
]
rule "Determine number of activated lights"
when
Item GlightsSfCounter received update or
Item GlightsSfWrCounter received update or
Item GlightsSfBarCounter received update or
Item GlightsSfLrCounter received update or
Item GlightsSfBerCounter received update or
Item GlightsSfCorCounter received update or
Item GswitchablesSfCounter received update or
Item GswitchablesSfWrCounter received update or
Item GswitchablesSfBerCounter received update
then
logInfo("counters", "rule execution")
logInfo("counters", "rule execution: item=" + triggeringItem.name)
val triggeringGroup = (triggeringItem as GroupItem)
updateNumberItem.apply(triggeringGroup, GassociatedCounters)
end
To get an understanding what happens when I execute the rule, here’s an excerpt of the openhab.log:
2018-07-15 15:25:39.494 [INFO ] [clipse.smarthome.model.script.motion] - No more motion in second floor living room: switching lights off
2018-07-15 15:25:39.536 [INFO ] [ipse.smarthome.model.script.counters] - rule execution
2018-07-15 15:25:39.542 [INFO ] [ipse.smarthome.model.script.counters] - rule execution
2018-07-15 15:25:39.556 [INFO ] [ipse.smarthome.model.script.counters] - rule execution: item=GlightsSfLrCounter
2018-07-15 15:25:39.561 [INFO ] [ipse.smarthome.model.script.counters] - rule execution: item=GlightsSfCounter
2018-07-15 15:25:39.573 [INFO ] [ipse.smarthome.model.script.counters] - updateNumberItem=GlightsSfCounter
2018-07-15 15:25:39.573 [INFO ] [ipse.smarthome.model.script.counters] - updateNumberItem=GlightsSfLrCounter
2018-07-15 15:25:39.665 [INFO ] [ipse.smarthome.model.script.counters] - update to IlightsSfLrCounter for group GlightsSfLrCounter: 0
2018-07-15 15:25:39.706 [INFO ] [ipse.smarthome.model.script.counters] - update to IlightsSfCounter for group GlightsSfCounter: 0
2018-07-15 15:25:49.603 [INFO ] [ipse.smarthome.model.script.counters] - rule execution
2018-07-15 15:25:49.614 [INFO ] [ipse.smarthome.model.script.counters] - rule execution: item=GlightsSfLrCounter
2018-07-15 15:25:49.607 [INFO ] [ipse.smarthome.model.script.counters] - rule execution
2018-07-15 15:25:49.621 [INFO ] [ipse.smarthome.model.script.counters] - rule execution: item=GlightsSfCounter
2018-07-15 15:25:49.634 [INFO ] [ipse.smarthome.model.script.counters] - updateNumberItem=GlightsSfLrCounter
2018-07-15 15:25:49.634 [INFO ] [ipse.smarthome.model.script.counters] - updateNumberItem=GlightsSfCounter
2018-07-15 15:25:49.656 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Determine number of activated lights': null
2018-07-15 15:25:49.679 [INFO ] [ipse.smarthome.model.script.counters] - update to IlightsSfLrCounter for group GlightsSfLrCounter: 0
I read [SOLVED] Error: Rule '<rulename>': null and grasped that I should use the triggeringItem which I now did.
Can this be a concurrency issue? (Only speculation since I do not have yet a decent understanding about how openHAB works internally)