Hi,
I have a question, and anybody can help me...
I'm using a digital input by Raspberry to count the wrist. The count is ok and its' works. The wrists is acummulated whit a counter node and every 30 seconds, the counts is sent to mqtt server and the reset is actived. All this is ok.
But the problem is when the connection drops.My logic is that the counter is not reset and continued to acummulated de count, until the connection returns. The problem, is that, when the connection returns, the final count is sent (is ok), but the initial count is sent too.
For exemple:
Is sent...1,2,3,4,5,6 (connection drops)....the count continues to 7,8,9,10....36,37,38....(connection returns).....the mqtt server receives the 38 count and the 6 count....(total of 44). I want to send only the final count....
Can I help me?
This is the program.....
[{"id":"598e0a39.f59d34","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"5675b580.61438c","type":"rpi-gpio in","z":"598e0a39.f59d34","name":"Entrada2","pin":"11","intype":"down","debounce":"25","read":false,"x":118.0000228881836,"y":296.99999809265137,"wires":[["5b2f2caa.4df8d4"]]},{"id":"5b2f2caa.4df8d4","type":"switch","z":"598e0a39.f59d34","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":279.0000686645508,"y":292.99999809265137,"wires":[["90f0293b.c47c78"]]},{"id":"90f0293b.c47c78","type":"counter","z":"598e0a39.f59d34","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":593,"y":298,"wires":[["7231d174.6b308"],]},{"id":"7231d174.6b308","type":"change","z":"598e0a39.f59d34","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"entrada/2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":757,"y":294,"wires":[["205d3d91.5ae362","4f80ef38.bd087"]]},{"id":"10696658.c33dda","type":"function","z":"598e0a39.f59d34","name":"","func":"out=context.data || {}\nnode.log("start" + msg.payload);\nnode.log("start stored" + context.data);\ntopic=msg.topic;\nnode.log(topic);\n\nif (msg.payload===true)\n{\n msg.payload=context.data;\n msg.out="Sent data to " +out.house;\n msg.topic="entradas/pulsos";\n context.data=null;\n return [msg];\n }\n \n\nelse\n{\n\n //topic=msg.topic;\n out[topic]=msg.payload;\n context.data=out;\n node.log("stored" + context.data);\n return null;\n}\n","outputs":1,"noerr":0,"x":1056.9999694824219,"y":142.00001621246338,"wires":[["5418dd2f.74d674"]]},{"id":"f7cc6ae.3a6db98","type":"inject","z":"598e0a39.f59d34","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":549.5000152587891,"y":93.00001335144043,"wires":[["cc000da6.5f459","10696658.c33dda"]]},{"id":"cc000da6.5f459","type":"change","z":"598e0a39.f59d34","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":589.4999923706055,"y":132.00000190734863,"wires":[["1b4bbe0f.95d6b2"]]},{"id":"5418dd2f.74d674","type":"json","z":"598e0a39.f59d34","name":"","property":"payload","action":"","pretty":false,"x":1101,"y":202.000018119812,"wires":[["89f83624.375d28"]]},{"id":"89f83624.375d28","type":"mqtt out","z":"598e0a39.f59d34","name":"","topic":"entradas/pulsos","qos":"2","retain":"","broker":"5e037932.401ff8","x":1199.5000305175781,"y":371.00000190734863,"wires":},{"id":"3ba7e9cd.533036","type":"mqtt in","z":"598e0a39.f59d34","name":"","topic":"entradas/pulsos","qos":"2","datatype":"auto","broker":"5e037932.401ff8","x":407.00000762939453,"y":524.3333711624146,"wires":[["d5ef4ecf.8ba0b"]]},{"id":"d5ef4ecf.8ba0b","type":"debug","z":"598e0a39.f59d34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":701.0000190734863,"y":525.3333702087402,"wires":},{"id":"205d3d91.5ae362","type":"debug","z":"598e0a39.f59d34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":824.0000228881836,"y":208.66668319702148,"wires":},{"id":"1b4bbe0f.95d6b2","type":"is online","z":"598e0a39.f59d34","name":"","url":"demo.alarmedecondominio.com.br","action":"1","x":594,"y":214.6666717529297,"wires":[["90f0293b.c47c78"]]},{"id":"4f80ef38.bd087","type":"is online","z":"598e0a39.f59d34","name":"","url":"demo.alarmedecondominio.com.br","action":"1","x":938,"y":294.6666564941406,"wires":[["10696658.c33dda"]]},{"id":"5e037932.401ff8","type":"mqtt-broker","z":"","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]