Hi,
I’m running OH2.5M1 on a RPi 3b.
I have a rule which is running quite fine as it is. It shows me the actual Firmware-States of my Sonoffs in BasicUI
val sonoff_device_ids = newArrayList("sonoffs")
rule "Sonoff Tasmota Release Version"
when
Item Sonoff_Release_Refresh changed to ON
or Channel 'astro:sun:local:noon#event' triggered START
or Channel 'astro:sun:local:night#event' triggered START
then
var firmware = transform("REGEX", ".*([0-9].[0-9].[0-9])", Sonoff_Current_FW_Available.state.toString)
logInfo("sonoff.rules", "Tasmota Refresh Items Release-State : " + firmware + "(sonoff)")
// This If-Statement causes an error when a Channel-Trigger is fired
// if (triggeringItem.state == ON) {
// logInfo("sonoff.rules", "Rule was manually fired: " + triggeringItem + " previousState: " + previousState)
// }
if (Sonoff_Release_Refresh.state == ON) {
logInfo("sonoff.rules", "Rule was manually fired: " + Sonoff_Release_Refresh + " previousState: " + previousState)
}
else {
logInfo("sonoff.rules", "Rule fired by Channel: ")
}
for (String device_id : sonoff_device_ids) {
publish("peter", "cmnd/" + device_id + "/status", "2")
logInfo("sonoff.rules", "Sonoff Maintenance: " + device_id)
}
logInfo("sonoff.rules", "Rule finished")
end
But when trying to use it more generally in this way:
if (triggeringItem.state == ON) {
logInfo("sonoff.rules", "Rule was manually fired: " + triggeringItem + " previousState: " + previousState)
}
to see if the Rule was triggered Item(Event)-based or Channel-based it causes an error, when the rule is triggered by a channel.
2019-07-29 06:54:00.638 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Sonoff Tasmota Release Version': cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.items.Item.getState() on null
Is there a possibility to realize the If-Statement in this more general way ?
I’m sitting here hour after hour, tried the weirdest combinations, but didn’t find a solution.
Any help is welcomed.
Cheers,
Peter