Your Rule is cool. Do you can help me for two things?
I have switches for LowBat all my Devices switch ON if the battery is low. But i’m too stupid to change the rule against switches.
The second rule i need is to check the status of things. I want an email if a thing goes offline. I searched and testet a lot, but i dont get an working rule for my problem.
Sorry. I mean things. I want a message if a thing goes offline. I created the things via paperUI and the items via *.items file. I add a group to one item per thing for the online status.
Also I add a other group to every lowBattery Switch item. If the lowBattery switch goes ON I wanted a message too.
It’s just a normal items file. I created an item per channel. The first item of a thing i added a group named „gOnline“.
My first idea was to iterate all items with the group „gOnline“ and check the state, but I don’t know how I can get the thing of an item. Tomorrow I can show you the files. Actually I havent access to my pc.
rule "Zwave Node5 status"
when
Thing "zwave:device:512:node5" changed
then
var thingStatusInfo = getThingStatusInfo("zwave:device:512:node5")
if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
logInfo("ThingStatus", "ZwaveNode5 is online.")
ZWaveNode5_status.postUpdate(ON)
} else {
logError("ThingStatus", "ZwaveNode5 is offline or doesn't exist.")
ZWaveNode5_status.postUpdate(OFF)
}
end
It requires a proxy item “ZwaveNode5_status”.
As Rich says, your cant group things, and you cant link an item directly to the thing status. So this is the only way I have got it to work. And you´ll have to make a simular rule as well as a simular proxy item for each thing.
Unfortunatly it´s a rule which means, when restarting openhab, and the thing is offline when the rule run, the rule will see the device as offline, and it will never change, for some reason I still havnt figured
Because the by the time the Rules are loaded, the Thing is already offline so there is no change to trigger the Rule to run. Put another way, the Rule missed the offline event.
You would need a System started Rule to somehow query all your Things to see which ones are already offline and manage them appropriately. Though I suspect adding a System started trigger to your already existing Rule might be sufficient.
I knew it somehow had to do with the rule running while the thing beeing offline at startup… I have thought about this, I just havn´t figured how to. I dont want to change the proxy item state to online, unless the thing is actually online. Thats the part I´m seem to get stucked on.
When you add a System started trigger to that Rule, at System startup is will look at that thing and only set the related Item to ON only if it is actually marked as ONLINE. In all other cases it sets the related Item to OFF.
Like I said, just adding a System started trigger to your existing Rules will be sufficient.