Simple project, but no reset

#1

Hi, my farming neighbour requested a simple flood irrigation alarm to wake him at night so he can go redirect the water, no problem I thought. But I am having major trouble testing and resetting it with the dash interface. A manual inject on the flow editor works but doing the same through the dash buttons does not work. No doubt I am making a simple mistake, and obvious to a different set of eyes

watering%20alarm%20flow|690x348

[{"id":"fffd6f7e.5a893","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4e4fa748.e09d28","type":"rpi-gpio out","z":"fffd6f7e.5a893","name":"Pin 12 Beacon light","pin":"12","set":true,"level":"0","freq":"","out":"out","x":970,"y":300,"wires":[]},{"id":"f6f50f25.47a3e","type":"exec","z":"fffd6f7e.5a893","command":"sudo shutdown -h now","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":700,"y":500,"wires":[[],[],[]]},{"id":"9788342c.ba0498","type":"ui_button","z":"fffd6f7e.5a893","name":"","group":"ab66c250.7caa","order":0,"width":0,"height":0,"passthru":false,"label":"Pi off","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":370,"y":500,"wires":[["f6f50f25.47a3e"]]},{"id":"93a49dd0.9c327","type":"ui_toast","z":"fffd6f7e.5a893","position":"top right","displayTime":"0.5","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"Water Alarm","name":"Water alarm activated","x":940,"y":180,"wires":[]},{"id":"a10e7066.149b3","type":"rpi-gpio in","z":"fffd6f7e.5a893","name":"","pin":"40","intype":"tri","debounce":"25","read":true,"x":150,"y":120,"wires":[["a01dde07.324c5"]]},{"id":"cf790043.5a58d","type":"inject","z":"fffd6f7e.5a893","name":"2 second flash","topic":"repeat","payload":"true","payloadType":"bool","repeat":"3","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":280,"wires":[["163ee65c.b4254a"]]},{"id":"163ee65c.b4254a","type":"and-gate","z":"fffd6f7e.5a893","name":"","rules":[{"t":"true","propertyType":"msg","property":"payload","topic":""},{"t":"true","propertyType":"msg","property":"payload","topic":"repeat"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":500,"y":260,"wires":[["c4981d8c.3edb1","62e54756.6e29b8"]]},{"id":"26844e68.65ea62","type":"inject","z":"fffd6f7e.5a893","name":"true","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":60,"wires":[["a01dde07.324c5"]]},{"id":"a01dde07.324c5","type":"change","z":"fffd6f7e.5a893","name":"binary to boolean","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":120,"wires":[["76f3b9e8.588638"]]},{"id":"c4981d8c.3edb1","type":"change","z":"fffd6f7e.5a893","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"Water level detected","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":240,"wires":[["f2bd01f.6a92d","93a49dd0.9c327"]]},{"id":"f2bd01f.6a92d","type":"ui_audio","z":"fffd6f7e.5a893","name":"","group":"ab66c250.7caa","voice":"en-GB","always":true,"x":1000,"y":240,"wires":[]},{"id":"e41e7d3c.a6724","type":"ui_button","z":"fffd6f7e.5a893","name":"","group":"ab66c250.7caa","order":0,"width":0,"height":0,"passthru":true,"label":"Reset Alarm","tooltip":"","color":"red","bgcolor":"","icon":"","payload":"false","payloadType":"bool","topic":"","x":170,"y":360,"wires":[["163ee65c.b4254a","598ce2c9.af328c"]]},{"id":"62e54756.6e29b8","type":"change","z":"fffd6f7e.5a893","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":300,"wires":[["4e4fa748.e09d28"]]},{"id":"21d4f9f1.9846c6","type":"inject","z":"fffd6f7e.5a893","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":420,"wires":[["163ee65c.b4254a","598ce2c9.af328c"]]},{"id":"76f3b9e8.588638","type":"ui_button","z":"fffd6f7e.5a893","name":"","group":"ab66c250.7caa","order":0,"width":0,"height":0,"passthru":true,"label":"Test alarm","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":150,"y":220,"wires":[["163ee65c.b4254a"]]},{"id":"598ce2c9.af328c","type":"debug","z":"fffd6f7e.5a893","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":380,"wires":[]},{"id":"ab66c250.7caa","type":"ui_group","z":"","name":"Water alarm","tab":"2e2e199b.c2d2d6","disp":true,"width":"6","collapse":true},{"id":"2e2e199b.c2d2d6","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
0 Likes

#2

I am not able to look at your flow, but if it works with an inject but not with a dashboard button then, assuming the two methods are going to the same nodes, there must be a difference in the message sent by the inject and by the button. Put a debug node showing what each is sending and compare them.

0 Likes

#3

In your flow you are using a non-default node, the and-gate. Pls specifiy full name so we can add it to our palettes

0 Likes

#4

[krambriw] npm install node-red-contrib-bool-gate,

Were you able to copy my flow or should I try to paste again? Is there a 'proper way' to post your flow on this forum?

0 Likes

#5

Sorry, I didn't mean that your flow was not importable, but I was on my phone.
What were the results of comparing the value you were injecting against the value sent by the dashboard button?

0 Likes

#6

If you add a change node after "Test alarm" and "Reset alarm" with the msg.topic set to an empty string, it will work. The reason for this is that the ui nodes does not add a topic to the msg themselves. The "topic" requirement is also stated in the info for the gate node.

topic(mandatory) string
the topic of the message. This is mandatory because of the node configuration

In addition, you might be considering to switch off the beacon light as well when initiating reset. It seems the light will never be turned off

0 Likes

#7

Thank you so much krambriw, Really appreciate your help.

I doubt I would have found that any time soon, I was just focusing on msg output not topic.
Completely missed that in the info window, won't be making that mistake again!
And yes, reset now linked to the beacon light.

0 Likes

#8

Thanks for your help Colin, turns out the topic was the problem not the payload as krambriw pointed out

0 Likes