OBi Connection Status Monitor & Alert

This flow checks the connection status of your Obihai OBi device every 30 seconds and will email and/or text you a notification if it's disconnected or otherwise not available.

You may need to download and install the www-request node to get this flow to work correctly. http://flows.nodered.org/node/node-red-contrib-http-request

I have only tested this with my OBi200, but it looks like all OBi devices have the same status page so it should work with other OBi devices too.

Nodes you'll need to edit are 'Set Variables', 'Check OBi Status', 'Send a Text Msg' & 'Send an Email'.

[{"id":"a1fef95d.b00f08","type":"tab","label":"Flow 1"},{"id":"9258e64b.fd31e8","type":"inject","z":"a1fef95d.b00f08","name":"Set Schedule","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":true,"x":120,"y":80,"wires":[["f1a44282.334b88"]]},{"id":"fca625cb.5669b8","type":"debug","z":"a1fef95d.b00f08","name":"Debug Output","active":true,"console":"false","complete":"payload","x":780,"y":240,"wires":[]},{"id":"f0e93aff.a7f828","type":"switch","z":"a1fef95d.b00f08","name":"Connected?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Normal (User Mode)","vt":"str"},{"t":"else"}],"checkall":"true","outputs":2,"x":110,"y":260,"wires":[["4a6c9c5.56b9ce4"],["30b21812.c31e6"]]},{"id":"6574963.2d58868","type":"function","z":"a1fef95d.b00f08","name":"Clear Headers","func":"msg.headers = null;\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":160,"wires":[["422ff7b3.5dbdf8"]]},{"id":"89c7a013.8e71d8","type":"www-request","z":"a1fef95d.b00f08","name":"Check OBi Status","method":"GET","ret":"txt","url":"http://192.168.1.2/DI_S_.xml","tls":"","x":130,"y":160,"wires":[["6574963.2d58868"]]},{"id":"4a6c9c5.56b9ce4","type":"change","z":"a1fef95d.b00f08","name":"Yes","rules":[{"t":"set","p":"payload","pt":"msg","to":"Connected","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":240,"wires":[["553ba9dd.b15238"]]},{"id":"30b21812.c31e6","type":"change","z":"a1fef95d.b00f08","name":"No","rules":[{"t":"set","p":"payload","pt":"msg","to":"Not Connected","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":280,"wires":[["3aef0390.a3d594"]]},{"id":"422ff7b3.5dbdf8","type":"xml","z":"a1fef95d.b00f08","name":"","attr":"","chr":"","x":510,"y":160,"wires":[["d55466c9.2778f"]]},{"id":"d55466c9.2778f","type":"json","z":"a1fef95d.b00f08","name":"","x":650,"y":160,"wires":[["f0e93aff.a7f828"]]},{"id":"67a4c0e6.84c7f8","type":"catch","z":"a1fef95d.b00f08","name":"","scope":["89c7a013.8e71d8"],"x":100,"y":360,"wires":[["241df6b7.06aef2"]]},{"id":"241df6b7.06aef2","type":"change","z":"a1fef95d.b00f08","name":"Error Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"error.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":360,"wires":[["3aef0390.a3d594"]]},{"id":"f1a44282.334b88","type":"function","z":"a1fef95d.b00f08","name":"Set Variables","func":"// Number of errors it takes to trigger an error\nflow.set(\"ErrorThreshold\",3);\n\n// Repeat the error notification every # of errors\nflow.set(\"ErrorRepeatEvery\",120);  // 0=disabled\n\n// Notification methods\nflow.set(\"SendEmail\",false);\nflow.set(\"SendTextMsg\",true);\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":80,"wires":[["89c7a013.8e71d8"]]},{"id":"3aef0390.a3d594","type":"function","z":"a1fef95d.b00f08","name":"Increment Error Count","func":"var ErrorCount = flow.get(\"ErrorCount\")||0;\nflow.set(\"ErrorCount\",++ErrorCount);\nmsg.payload += \"(\" + ErrorCount + \")\";\n\nif (ErrorCount % flow.get(\"ErrorRepeatEvery\") === 0) {\n  flow.set(\"ErrorRepeat\",ErrorCount);    \n} else {\n  flow.set(\"ErrorRepeat\",0);\n}\nreturn msg;","outputs":"1","noerr":0,"x":560,"y":360,"wires":[["a57bb264.cc2b4"]]},{"id":"50de87be.80851","type":"e-mail","z":"a1fef95d.b00f08","server":"smtp.gmail.com","port":"465","secure":true,"name":"","dname":"Send an Email","x":780,"y":560,"wires":[]},{"id":"bc0395e6.dcc83","type":"switch","z":"a1fef95d.b00f08","name":"Notify By Email?","property":"SendEmail","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":540,"y":560,"wires":[["50de87be.80851"]]},{"id":"cb15e640.1fa81","type":"switch","z":"a1fef95d.b00f08","name":"Notify By Text Msg?","property":"SendTextMsg","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":550,"y":500,"wires":[["e29ab38d.626248"]]},{"id":"e29ab38d.626248","type":"e-mail","z":"a1fef95d.b00f08","server":"smtp.gmail.com","port":"465","secure":true,"name":"","dname":"Send a Text Msg","x":790,"y":500,"wires":[]},{"id":"32db1f34.ddc388","type":"comment","z":"a1fef95d.b00f08","name":"Sending a Text Msg Info","info":"Send an email to 10DigitPhoneNumber@ below address\nExample: [email protected]\n\nU.S. Carrier    SMS Gateway\nAltel           @sms.alltelwireless.com\nAT&T            @txt.att.net\nBoost Mobile    @sms.myboostmobile.com\nSprint          @messaging.sprintpcs.com\nT-Mobile        @tmomail.net\nU.S. Cellular   @email.uscc.net\nVerizon         @vtext.com\nVirgin Mobile   @vmobl.com\n\nMore Info:\nhttp://www.digitaltrends.com/computing/how-to-send-free-text-messages-online/\nhttps://20somethingfinance.com/how-to-send-text-messages-sms-via-email-for-free/","x":800,"y":460,"wires":[]},{"id":"227d9b16.dde254","type":"catch","z":"a1fef95d.b00f08","name":"","scope":["e29ab38d.626248","50de87be.80851"],"x":100,"y":420,"wires":[["7c4ff1b2.e5659"]]},{"id":"7c4ff1b2.e5659","type":"change","z":"a1fef95d.b00f08","name":"Error Message","rules":[{"t":"set","p":"payload","pt":"msg","to":"error.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":420,"wires":[["fca625cb.5669b8"]]},{"id":"a57bb264.cc2b4","type":"function","z":"a1fef95d.b00f08","name":"Trigger Error?","func":"if (flow.get(\"ErrorCount\") === flow.get(\"ErrorThreshold\") ||\n    flow.get(\"ErrorCount\") === flow.get(\"ErrorRepeat\")) {\n  return [msg, null];\n} else {\n  return [null, msg];\n}","outputs":"2","noerr":0,"x":780,"y":360,"wires":[["fca625cb.5669b8","cb15e640.1fa81","bc0395e6.dcc83"],["fca625cb.5669b8"]]},{"id":"4d7699aa.7dbc28","type":"comment","z":"a1fef95d.b00f08","name":"About","info":"v1.0\nObi Status / By MrTom / April 2017\n----------------------------------\n___\nChecks the connection status of your Obihai OBi\ndevice every 30 seconds and will email and/or\ntext you a notification if it's disconnected or\notherwise not available.","x":90,"y":20,"wires":[]},{"id":"553ba9dd.b15238","type":"change","z":"a1fef95d.b00f08","name":"Clear Error","rules":[{"t":"set","p":"ErrorCount","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":240,"wires":[["fca625cb.5669b8"]]}]

Flow Info

Created 7 years, 7 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • catch (x2)
  • change (x5)
  • comment (x2)
  • debug (x1)
  • function (x4)
  • inject (x1)
  • json (x1)
  • switch (x3)
  • xml (x1)
Other
  • e-mail (x2)
  • tab (x1)
  • www-request (x1)

Tags

  • OBiHai
  • OBi
  • Status
  • Monitor
  • Alert
  • email
  • text
  • connection
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option