Agile sensortag with auto-reconnect

Continuously(every 15 sec) monitoring of the device connection state, and auto-reconnecting device, when it goes disconnected.

[{"id":"736ff3ac.3c173c","type":"inject","z":"31045c14.9e5004","name":"","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":false,"x":378,"y":214,"wires":[["4df4dbb.443ce24"]]},{"id":"4df4dbb.443ce24","type":"exec","z":"31045c14.9e5004","command":"curl -X GET --header 'Accept: application/json' 'http://agile-core:8080/api/device/bleB0B448BD1085/status'","addpay":true,"append":"","useSpawn":"","timer":"15","name":"DeviceStatus","x":560,"y":211.5,"wires":[["1c381ca0.fe5d03"],[],[]]},{"id":"eefe5558.548bd8","type":"debug","z":"31045c14.9e5004","name":"","active":true,"console":"false","complete":"false","x":893.5,"y":169,"wires":[]},{"id":"1c381ca0.fe5d03","type":"function","z":"31045c14.9e5004","name":"IsDisconnected","func":"if (JSON.parse(msg.payload).status == \"DISCONNECTED\")\n    return msg;\nelse\n    return null;","outputs":1,"noerr":0,"x":750,"y":214,"wires":[["eefe5558.548bd8","6be4b474.ffc81c"]]},{"id":"6be4b474.ffc81c","type":"exec","z":"31045c14.9e5004","command":"curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://agile-core:8080/api/device/bleB0B448BD1085/connection'","addpay":false,"append":"","useSpawn":"","timer":"15","name":"DeviceConnect","x":959.5,"y":212,"wires":[[],[],[]]},{"id":"52c11a0a.df7f84","type":"debug","z":"31045c14.9e5004","name":"","active":false,"console":"false","complete":"false","x":710,"y":350,"wires":[]},{"id":"93baa767.2ea168","type":"function","z":"31045c14.9e5004","name":"","func":"value = JSON.parse(msg.payload).value;\nif (value != 255) \n    return {payload: value};\nelse\n    return null;","outputs":1,"noerr":0,"x":551,"y":424,"wires":[["52c11a0a.df7f84","8da0799.5e3c388","49a9f295.fd1cdc"]]},{"id":"8da0799.5e3c388","type":"ui_chart","z":"31045c14.9e5004","name":"Optical","group":"7266dc23.cc82f4","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"30","removeOlderUnit":"1","x":713,"y":398,"wires":[[],[]]},{"id":"1bb7217a.c274df","type":"websocket in","z":"31045c14.9e5004","name":"Subscribe.Optical","server":"","client":"f7a1964f.7b02e8","x":399,"y":369,"wires":[["93baa767.2ea168","52c11a0a.df7f84"]]},{"id":"49a9f295.fd1cdc","type":"ui_gauge","z":"31045c14.9e5004","name":"Optical","group":"7266dc23.cc82f4","order":0,"width":0,"height":0,"gtype":"gage","title":"Gauge","label":"units","format":"{{value}}","min":"30","max":"150","colors":["#00b500","#e6e600","#ca3838"],"x":716,"y":444,"wires":[]},{"id":"9e5456e1.5dd5b8","type":"inject","z":"31045c14.9e5004","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":776,"y":257,"wires":[["6be4b474.ffc81c"]]},{"id":"7266dc23.cc82f4","type":"ui_group","z":"31045c14.9e5004","name":"Default","tab":"96d813ad.1d73a","disp":true,"width":"6"},{"id":"f7a1964f.7b02e8","type":"websocket-client","z":"31045c14.9e5004","path":"ws://agile-core:8080/ws/device/bleB0B448BD1085/Optical/subscribe","wholemsg":"false"},{"id":"96d813ad.1d73a","type":"ui_tab","z":"31045c14.9e5004","name":"Sensors","icon":"dashboard"}]
doitdagi

Flow Info

created 5 months, 3 weeks ago

Node Types

Core
  • debug (x2)
  • exec (x2)
  • function (x2)
  • inject (x2)
  • websocket in (x1)
  • websocket-client (x1)
Other
  • ui_chart (x1)
  • ui_gauge (x1)
  • ui_group (x1)
  • ui_tab (x1)

Tags

  • AGILE
  • Auto-reconnect
  • sennsor-tag
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option