Please, proceed carefully following the tips published in this blog, specially when Main Power is involved. I'm not responsible for any damages caused by what is written in this blog.
Thank you

Tuesday, 24 October 2017

Home Automation System - OpenHAB v.2, a better network monitoring with groups

Introducing the openhab groups in my setup, I improved my network monitoring.

I created a new group called gNetworkCheck, which will be assigned to all the network devices I would like to monitor. This group will be ON when all items will be ON, otherwise OFF.

Then I changed the monitoring rule, defining it only for the group and not for every device; in this way, I could add a new device to monitor simply assigning it to the gNetworkCheck group; no new rules to write.

So, I edited my /etc/openhab2/rules/checks.rules file, replacing all the specific device rules with a single rule for the group:

rule "network check"
Item gNetworkCheck changed
val lastItem = gNetworkCheck.members.sortBy[lastUpdate].last
logInfo("rules", "NETWORK CHECK -> " + lastItem.name + " changed to " + lastItem.state)
sendNotification([user_to_be_notified], "NETWORK CHECK -> " + lastItem.name + " changed to " + lastItem.state)

Following a tip found in the OpenHAB forum (https://community.openhab.org/t/determining-the-triggering-item-in-the-body-of-a-rule/2654/4?u=alex73) I'm able to identify the item changed, which I added to the notification message.

Here is the sitemap with the new group on it

No comments:

Post a Comment