我想在 openHAB2 中编写一个规则,它增加所有组项的计数器。这几项:
Group counters
Number cnt1 (counters)
Number cnt2 (counters)
我的规则尝试:
rule "Increase value .1 per minute"
when
Time cron "0 * * * * ?" or
System started
then
// Initialize. Necessary?
counters?.members.forEach(counter|
postUpdate(counter, 0.0)
)
counters?.members.forEach(counter|
postUpdate(counter, 0.1 + counter.state)
}
end
但这不起作用。例外:
Error during the execution of startup rule 'Increase value .1 per minute': Could not invoke method: org.eclipse.xtext.xbase.lib.DoubleExtensions.operator_plus(double,byte) on instance: null
我试图探索 counter.state 的类型,并用logInfo(counter.state.class)
它正确地记录日志...DecimalType
。