Clear Alarm

39 views
Skip to first unread message

Nate Damm

unread,
Apr 25, 2017, 11:08:11 PM4/25/17
to Node-RED
Not sure If this would be the correct term to use to describe this.

Problem:
I have a flow that sends me an alert when I loose comms to a sensor or device for 30 minutes, I wanted a way to get a follow up message when they started
communicating again. 

My google-fu failed to find a node to do this, or any methods to achieve what I was looking for

Solution:

I noticed the throttle node could be held closed until msg.reset was set, then I found my solution

[{"id":"1f8556f4.45be19","type":"trigger","z":"e6ae5fc7.bdd91","op1":"","op2":"No comms for 30 minutes","op1type":"nul","op2type":"str","duration":"30","extend":true,"units":"min","reset":"","name":"","x":280,"y":100,"wires":[["c64818f5.197178","153e716d.56473f","976afb91.a60e48"]]},{"id":"c64818f5.197178","type":"throttle","z":"e6ae5fc7.bdd91","name":"","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"locked":true,"x":780,"y":100,"wires":[["4af5515.30763b"]]},{"id":"24cac15f.185f4e","type":"change","z":"e6ae5fc7.bdd91","name":"clear","rules":[{"t":"set","p":"reset","pt":"msg","to":"false","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":80,"wires":[["c64818f5.197178"]]},{"id":"153e716d.56473f","type":"change","z":"e6ae5fc7.bdd91","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"I'm talking again","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":120,"wires":[["c64818f5.197178"]]},{"id":"976afb91.a60e48","type":"delay","z":"e6ae5fc7.bdd91","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":80,"wires":[["24cac15f.185f4e"]]}]


Nate Damm

unread,
Apr 25, 2017, 11:50:22 PM4/25/17
to Node-RED
Woopsie, I wired that wrong from my test page to when i took the screenshot



[{"id":"20bae410.fa05ac","type":"inject","z":"7321d8f7.a6e0b8","name":"input","topic":"","payload":"13","payloadType":"str","repeat":"","crontab":"","once":false,"x":630,"y":140,"wires":[["90bb46b6.21e7b8","a1a0217d.fc6a1","543b4f92.eb909"]]},{"id":"90bb46b6.21e7b8","type":"trigger","z":"7321d8f7.a6e0b8","op1":"","op2":"Comms Out","op1type":"nul","op2type":"str","duration":"20","extend":true,"units":"s","reset":"","name":"20 S trigger","x":830,"y":160,"wires":[["3b6de6d6.e6ce6a","ef3b73e4.7b2d3"]]},{"id":"a1a0217d.fc6a1","type":"throttle","z":"7321d8f7.a6e0b8","name":"","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"locked":true,"x":1160,"y":140,"wires":[["8db3701d.20b41"]]},{"id":"8db3701d.20b41","type":"debug","z":"7321d8f7.a6e0b8","name":"","active":true,"console":"false","complete":"false","x":1350,"y":140,"wires":[]},{"id":"4033c1e3.74c82","type":"change","z":"7321d8f7.a6e0b8","name":"clear","rules":[{"t":"set","p":"reset","pt":"msg","to":"false","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":120,"wires":[["a1a0217d.fc6a1"]]},{"id":"ef3b73e4.7b2d3","type":"change","z":"7321d8f7.a6e0b8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"I'm talking again","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":160,"wires":[["a1a0217d.fc6a1"]]},{"id":"543b4f92.eb909","type":"delay","z":"7321d8f7.a6e0b8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":840,"y":120,"wires":[["4033c1e3.74c82"]]}]


Julian Knight

unread,
Apr 26, 2017, 11:01:59 AM4/26/17
to Node-RED
Are you using MQTT?

I use a Last Will & Testament with a flow that pushes to MQTT on receipt of a sensor reading. Then if the MQTT topic doesn't receive another message for more than the sensor timeout (a minute for me generally), it triggers the LWT. 

Sensor Reading -> Sensor data to MQTT
               
-> "Online" msg to another MQTT topic with LWT that issues an "Offline" msg if not updated every 1min

Nate Damm

unread,
Apr 26, 2017, 9:14:57 PM4/26/17
to Node-RED
I am using MQTT, but the server is at my house, and the sensors/node-red are remote, so if the MQTT server looses internet then I get no alerts, but since node-red is remote I get a slack alert that my sensors are offline.

I was also wrong on both of those 2 demos I posted above, that's what I get for doing this right before I goto bed.
Here's the current version, which works as I had intended last night.




[{"id":"89712f6d.73932","type":"inject","z":"24dc18bd.1a2ff8","name":"input","topic":"","payload":"13","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":240,"wires":[["ae434266.cd3fb","a4405907.b30458","aadff81e.458958"]]},{"id":"ae434266.cd3fb","type":"trigger","z":"24dc18bd.1a2ff8","op1":"","op2":"Sensor not communicating for 30 mins","op1type":"nul","op2type":"str","duration":"20","extend":true,"units":"s","reset":"","name":"20s trigger","x":330,"y":280,"wires":[["acb46072.8787c","bd87d73e.f8f068"]]},{"id":"ca5f3b0.1e8f6c8","type":"throttle","z":"24dc18bd.1a2ff8","name":"door","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"locked":true,"x":630,"y":240,"wires":[["bd87d73e.f8f068"]]},{"id":"bd87d73e.f8f068","type":"debug","z":"24dc18bd.1a2ff8","name":"","active":true,"console":"false","complete":"false","x":790,"y":280,"wires":[]},{"id":"16b79b33.e93855","type":"change","z":"24dc18bd.1a2ff8","name":"close","rules":[{"t":"set","p":"reset","pt":"msg","to":"false","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":220,"wires":[["ca5f3b0.1e8f6c8"]]},{"id":"acb46072.8787c","type":"change","z":"24dc18bd.1a2ff8","name":"open","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":260,"wires":[["ca5f3b0.1e8f6c8"]]},{"id":"aadff81e.458958","type":"delay","z":"24dc18bd.1a2ff8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":340,"y":200,"wires":[["16b79b33.e93855"]]},{"id":"a4405907.b30458","type":"change","z":"24dc18bd.1a2ff8","name":"Comms Up","rules":[{"t":"set","p":"payload","pt":"msg","to":"Comms are back up!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":240,"wires":[["ca5f3b0.1e8f6c8"]]}]


Reply all
Reply to author
Forward
0 new messages