Telegram - Flow spams a lot of messages

Hello,

I will explain my problem in this flow in order not to get involved with all the nodes. So trigger node is sending every one second "the existing msg object". Function "Fire" has a value which I want to be decreased every 1 second and that's why I used trigger node (I don't know if there is another way to do that). The problem is that I want to use 1 switch "Sprinkler" and get notified once when its activated and once when its disabled. In this flow this doesn't happen and I got spammed every 1 second in my telegram's chat when switch is activated. Is there any way to trigger function "Fire" until its value becomes less than 20 and only get once the message "Sprinkler is activated"?

Thanks for your time, appreciate your help !
(I really appreciate the help that I got with my previous questions in this forum!)


image

Flow:

[{"id":"6b9a429a.93b7fc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4765540f.a4a98c","type":"ui_gauge","z":"6b9a429a.93b7fc","name":"Temperature Adjustment","group":"2d70c600.e2d54a","order":6,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Celsius","format":"{{value}}","min":"20","max":"60","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":990,"y":320,"wires":[]},{"id":"208f6d80.83bff2","type":"function","z":"6b9a429a.93b7fc","name":"Fire ","func":"\nvar counter = flow.get('counter')\nmsg.payload = counter; \nif(counter<20)\n{\n   return 0;\n}\nelse\n{\ncounter=counter-1;\n}\nflow.set(\"counter\",counter);\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":790,"y":300,"wires":[["4765540f.a4a98c","de8a118.51d7ff","a82509ce.5002e8"]]},{"id":"19e164fc.fcfb7b","type":"telegram command","z":"6b9a429a.93b7fc","name":"App","command":"/sprinkler","bot":"2f6c1f7b.9d7c1","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":130,"y":420,"wires":[["4b1c980a.ce31c8"]]},{"id":"4b1c980a.ce31c8","type":"switch","z":"6b9a429a.93b7fc","name":"on / off ","property":"originalMessage.text","propertyType":"msg","rules":[{"t":"eq","v":"/sprinkler on","vt":"str"},{"t":"eq","v":"/sprinkler off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":420,"wires":[["b7b2f2d6.0df95"],["1fb932a6.a0854d"]]},{"id":"cbecdbae.367558","type":"switch","z":"6b9a429a.93b7fc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":420,"wires":[["4bff509.9b2dcb"],["27bbb3d2.aa39fc"]]},{"id":"4bff509.9b2dcb","type":"change","z":"6b9a429a.93b7fc","name":"Activated","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"chatId\":1709611765,\"type\":\"message\",\"content\":\"Sprinkler Activated\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":420,"wires":[["faebf9b3.e471c8"]]},{"id":"27bbb3d2.aa39fc","type":"change","z":"6b9a429a.93b7fc","name":"Deactivated","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"chatId\":1709611765,\"type\":\"message\",\"content\":\"Sprinkler Deactivated\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":460,"wires":[["faebf9b3.e471c8"]]},{"id":"faebf9b3.e471c8","type":"telegram sender","z":"6b9a429a.93b7fc","name":"","bot":"2f6c1f7b.9d7c1","haserroroutput":false,"outputs":1,"x":1130,"y":440,"wires":[[]]},{"id":"b7b2f2d6.0df95","type":"change","z":"6b9a429a.93b7fc","name":"True","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":400,"wires":[["fd292f58.16fc3"]]},{"id":"1fb932a6.a0854d","type":"change","z":"6b9a429a.93b7fc","name":"False","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":440,"wires":[["fd292f58.16fc3"]]},{"id":"fd292f58.16fc3","type":"ui_switch","z":"6b9a429a.93b7fc","name":"Sprinkler","label":"Sprinkler ","tooltip":"","group":"2d70c600.e2d54a","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"payload.content","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":620,"y":420,"wires":[["cbecdbae.367558"]]},{"id":"3880961.732816a","type":"link in","z":"6b9a429a.93b7fc","name":"Link In","links":["898248ee.bca0b8"],"x":535,"y":380,"wires":[["fd292f58.16fc3"]]},{"id":"898248ee.bca0b8","type":"link out","z":"6b9a429a.93b7fc","name":"Link Out","links":["3880961.732816a","b0e96e76.15ec4"],"x":1235,"y":260,"wires":[]},{"id":"36ae6c20.53fdc4","type":"trigger","z":"6b9a429a.93b7fc","name":"","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"-1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":600,"y":300,"wires":[["208f6d80.83bff2"]]},{"id":"15e1b11f.9ead3f","type":"function","z":"6b9a429a.93b7fc","name":"Data Generation","func":"flow.set(\"counter\", Math.round(Math.random()*(60 - 20) + 20));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":300,"wires":[["36ae6c20.53fdc4"]]},{"id":"89c4b282.789f9","type":"inject","z":"6b9a429a.93b7fc","name":"Temperature Sensor","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":300,"wires":[["15e1b11f.9ead3f"]]},{"id":"41e858f6.1b2858","type":"change","z":"6b9a429a.93b7fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":280,"wires":[["898248ee.bca0b8"]]},{"id":"de8a118.51d7ff","type":"switch","z":"6b9a429a.93b7fc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"20","vt":"num"},{"t":"lte","v":"20","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":930,"y":260,"wires":[["63eec760.a51078"],["41e858f6.1b2858"]]},{"id":"63eec760.a51078","type":"change","z":"6b9a429a.93b7fc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":240,"wires":[["898248ee.bca0b8"]]},{"id":"a82509ce.5002e8","type":"debug","z":"6b9a429a.93b7fc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":360,"wires":[]},{"id":"2d70c600.e2d54a","type":"ui_group","name":"Example","tab":"c0a2130d.da022","order":1,"disp":true,"width":"6","collapse":false},{"id":"2f6c1f7b.9d7c1","type":"telegram bot","botname":"christs99_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"c0a2130d.da022","type":"ui_tab","name":"Alarm","icon":"dashboard","disabled":false,"hidden":false}]

Put an RBE after the switch

image

1 Like

It was that simple I used RBE but not there, and it didn't work... Thank you !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.