Hi!
I'm building a solution that let's us verify at a glance if some heating elements have been turned on (and not malfunctioned) for a predetermined time.
ie I set the electromechanical timer for 5h and let the heating element heat. When I come back the next day I want to verify that it really heated for at least 5h. I'm using Shelly EM elements to measure the consumed power.
So the Shellies send ~0W most of the time, as each machine has it's own electrical circuit.
When I turn the timer on the heating element draws 100W and when the timer turns off the consumption goes back to ~0W.
My plan is to generate a timestamp when consumption goes over 100W, unblock the stop trigger, so it can generate a timestamp when the consumption goes under 100W. To avoid triggering too easily I have a smooth node that averages 10 latest values.
Once the cycle has completed I'll reset the time calculation manually - so also the gate and the triggers.
My flow is as follows:
It uses a few custom nodes:
node-red-node-smooth to pass on the average of last 10ish readings, to weed out random errors
node-red-contrib-shelly to communicate with the shelly (could be done directly with mqtt as well)
node-red-contrib-simple-gate to block generating stop timestamp before the start timestamp has been generated
[{"id":"821607c2e9020d15","type":"shelly-gen1","z":"452ab868.195118","hostname":"192.168.1.151","description":"A & B","pollinginterval":"10000","pollstatus":true,"getstatusoncommand":true,"devicetype":"Measure","outputs":2,"x":710,"y":860,"wires":[["25e2a970d7b8f5bf"],[]]},{"id":"25e2a970d7b8f5bf","type":"change","z":"452ab868.195118","name":"Select W","rules":[{"t":"move","p":"payload.emeters[0].power","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":940,"wires":[["89074d5994c7a130"]]},{"id":"89074d5994c7a130","type":"rbe","z":"452ab868.195118","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":710,"y":1000,"wires":[["39b43ebfd131e3e1"]]},{"id":"2dacbb961efd608b","type":"trigger","z":"452ab868.195118","name":"start timestamp","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1180,"y":1000,"wires":[["2d2b791756cded63","c3eda38b31f8f3fd"]]},{"id":"f468ec71a6996ebc","type":"switch","z":"452ab868.195118","name":"if >100","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"100","vt":"num"},{"t":"lt","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":1040,"wires":[["2dacbb961efd608b"],[]]},{"id":"39b43ebfd131e3e1","type":"smooth","z":"452ab868.195118","name":"","property":"payload","action":"mean","count":"10","round":"1","mult":"single","reduce":true,"x":720,"y":1060,"wires":[["f468ec71a6996ebc","f922cf8d6c4be0fb"]]},{"id":"fb665f00b6be17af","type":"trigger","z":"452ab868.195118","name":"stop timestamp","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1180,"y":1160,"wires":[["8da96d449d6eabb4","c3eda38b31f8f3fd"]]},{"id":"2d2b791756cded63","type":"change","z":"452ab868.195118","name":"open gate after start","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":1080,"wires":[["2a041f0878c3ea2f"]]},{"id":"2a041f0878c3ea2f","type":"gate","z":"452ab868.195118","name":"","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":true,"storeName":"memory","x":1010,"y":1160,"wires":[["fb665f00b6be17af"]]},{"id":"f922cf8d6c4be0fb","type":"switch","z":"452ab868.195118","name":"if <100","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":1080,"wires":[["2a041f0878c3ea2f"]]},{"id":"8da96d449d6eabb4","type":"change","z":"452ab868.195118","name":"close gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":1260,"wires":[["2a041f0878c3ea2f"]]},{"id":"c3eda38b31f8f3fd","type":"function","z":"452ab868.195118","name":"elapsed time calculation","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1490,"y":1060,"wires":[[]]}]
My question is: does this look like a working solution? Would there be important bottlenecks that are glaringly obvious? Also, I have 10 measures like this to set up.