[SOLVED] Watchdog Expire Alerting - Hope I Am On The Right Track


(Clint Crowe) #1
  • Platform information:

    • Hardware: Pi
    • OS: Openhabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: openhabian 2.3.0-1
  • Issue of the topic: I have my expire binding working just peachy. Turns the tower pumps on every fifteen minutes and runs for 3 minutes. I am now working on an alert to let me know if the timer fails. This is what I have so far. Not where I can test it tonight but thought I would get some feedback that I am on the right track.

    • Items configuration related to the issue
Switch TowerPump_watchdog { expire="30m" } //If ON the switch will go back to OFF after 30m
  • Sitemap configuration related to the issue

Is there something that can be put in the sitemap to alert?

  • Rules code related to the issue
    the inovelli is the zwave controller (item).
rule "Tower Pump changed"
when
    inovelli_plug1 changed
then
    TowerPump_watchdog.sendCommand(ON) // resets the watchdog
end

rule "Tower Pump Watchdog"
when
    Item TowerPump_watchdog changed from ON to OFF
then
    // Do what you want if watchdog triggered
    logInfo("WARNING","Tower Pump is OFFLINE")
	sendMail("alerts@mygmail.com", "TOWER FAILURE: Pump Has Not Run", "Pump Failure Detected")
	sendNotification(userName, Tower Pump Failure!)
end

Like I said, have not run it yet but once I do I can post the logs.

Thanks!


(Anders Alfredsson) #2

It depends: is the inovelli_plug1 switched externally and then reports to openhab? Then it should work. But if it’s triggered from openhab then it’s state will likely change regardless of if it’s actually working, and the watchdog won’t be of any use. This can possibly be solved by adding autoupdate="false" to it’s channel definition.

And, just a heads up: You need to add Item to the trigger in the first rule

when
    Item inovelli_plug1 changed
then

And the arguments to sendNotification should be quoted

sendNotification("userName", "Tower pump failiure!")

(Clint Crowe) #3

Thanks Anders!

I was able to install this afternoon and the rule throws an error. This is the code I came up with for the rule:

rule "Tower Pump changed"
when
    item inovelli_plug1 changed
then
    TowerPump_watchdog.sendCommand(ON) // resets the watchdog
end

rule "Tower Pump Watchdog"
when
    Item TowerPump_watchdog changed from ON to OFF
then
    // Do what you want if watchdog triggered
    logInfo("WARNING","Tower Pump is OFFLINE")
	sendMail("name@gmail.com", "TOWER FAILURE: Pump Has Not Run", "Pump Failure Detected")
	sendNotification("name@gmail.com", "Tower Pump Failure!")
end

This is the error:

Configuration model ‘toweralert.rules’ has errors, therefore ignoring it: [3,5]: no viable alternative at input ‘item’


(Anders Alfredsson) #4

It needs to be with a capital I: Item not item


(Clint Crowe) #5

Thanks Anders! Well that help it load without errors. I unplugged the inovelli to see what would happen.

I get this error:

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Tower Pump changed': The name 'TowerPump_watchdog' cannot be resolved to an item or type; line 5, column 5, length 18

I also got this one:

[hingStatusInfoChangedEvent] - 'zwave:device:2f31014c:node5' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Node is not communicating with controller

(Clint Crowe) #6

I had this show up too…

[vent.ItemStateChangedEvent] - TowerHeartBeat changed from OFF to UNDEF

(Vincent Regaud) #7
Switch TowerPump_watchdog { expire="30m,command=OFF" } //If ON the switch will go back to OFF after 30m

command=OFF will send an OFF command after 30 minutes otherwise the item will get updated to UNDEF after 30 minutes.

From the docs:
This section can optionally be followed by a comma and the state or command to post when the timer expires. When this optional section is not present, it defaults to posting an Undefined (UnDefType.UNDEF) update to the item.

It is TowerHeartBeat or TowerPump_watchdog ?


(Rich Koshak) #8

I have no idea if this will work but perhaps something like this will work. I’ve never tried multiple expire bindings on the same Item.

Switch inovelli_plug1 { expire="3m,OFF", expire="30m" }
rule "Tower Pump Watchdog"
when
    Item inovelli_plug1 changed to NULL
then
    logInfo("WARNING","Tower Pump is OFFLINE")
    sendMail("alerts@mygmail.com", "TOWER FAILURE: Pump Has Not Run", "Pump Failure Detected")
    sendNotification(userName, Tower Pump Failure!)
end

I’m not sure there won’t be problems here on the reload of a .items file or system startup. But if it works, it lest the inovelli_plug1 be its own watchdog. You cna use the color tag in the sitemap to make your Item label red or something like that .

labelcolor=[UNDEF="red"]

I think that will work.

If you want something more comprehensive for tracking the online status of these and other Items in a centralized manner you can do something like: Design Patterns: Generic Is Alive (note I need to rewrite this DP) or Design Pattern: Sensor Aggregation


(Clint Crowe) #9

Thanks Rick, I am going to create new files and try that out.

I made the changes from Vincent in my current code. this is what I get. in the logs.

This is just about the time that i unplugged the inovelli:

2018-06-13 13:37:41.303 [vent.ItemStateChangedEvent] - inovelli_plug1 changed from ON to OFF

I then got this. This looks like what I really want to trigger an alert on!

2018-06-13 13:48:43.651 [hingStatusInfoChangedEvent] - 'zwave:device:2f31014c:node5' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Node is not communicating with controller

Then it just continued to do this:

2018-06-13 13:54:00.038 [ome.event.ItemCommandEvent] - Item 'inovelli_plug1' received command ON

2018-06-13 13:54:00.062 [vent.ItemStateChangedEvent] - inovelli_plug1 changed from OFF to ON

2018-06-13 13:57:00.360 [ome.event.ItemCommandEvent] - Item 'inovelli_plug1' received command OFF

2018-06-13 13:57:00.386 [vent.ItemStateChangedEvent] - inovelli_plug1 changed from ON to OFF

2018-06-13 14:00:00.058 [ome.event.ItemCommandEvent] - Item 'inovelli_plug1' received command ON

2018-06-13 14:00:00.092 [vent.ItemStateChangedEvent] - inovelli_plug1 changed from OFF to ON

2018-06-13 14:03:00.442 [ome.event.ItemCommandEvent] - Item 'inovelli_plug1' received command OFF

2018-06-13 14:03:00.478 [vent.ItemStateChangedEvent] - inovelli_plug1 changed from ON to OFF

At the 14:06 mark i should get an alert and i do not. logs keep no showing the device on/off.

thanks!


(Rich Koshak) #10

That’s right. The Rule keeps on updating the Item so we can’t rely on the ON/OFF commands sent to this Item to know whether it is online because WE are generating the commands, not the device.

There might be something you can use here, in particular the Thing Rule trigger, which I’ve not used so don’t have a good feel for how well it works.


(Clint Crowe) #11

That sense.

Thanks for that link. I will try that next! That looks like what I am looking for as long as that notice is consistent.


(Clint Crowe) #12

This is great! I have the rule working as a THING alert. Works perfect. I alerts me through Openhab and sends out emails to myself and others so that we can react. Very cool. Thanks for all the help!

here is the code to help others out!

rule "Towers offline"
when
    Thing "zwave:device:2f31014c:node5" changed from ONLINE to OFFLINE
then
    logWarn("TowerOffline", "Towers are OFFLINE!")
    sendNotification("myopenhabaccount@domain.com", "Towers are OFFLINE!")
    sendMail("myemail@domain.com", "Tower Pump is OFFLINE!", "Tower Pump is OFFLINE!")
end

rule "Towers online"
when
    Thing "zwave:device:2f31014c:node5" changed from OFFLINE to ONLINE
then
    logWarn("TowerOnline", "Towers are ONLINE!")
    sendNotification("myopenhabaccount@domain.com", "Towers are ONLINE!")
    sendMail("myemail@domain.com", "Tower Pump is ONLINE!", "Tower Pump is ONLINE!")
end