Skip to content

Instantly share code, notes, and snippets.

@comfortliner
Last active January 15, 2022 22:37
Show Gist options
  • Save comfortliner/5fa4530ff24697952124a89ce4821d36 to your computer and use it in GitHub Desktop.
Save comfortliner/5fa4530ff24697952124a89ce4821d36 to your computer and use it in GitHub Desktop.
Power Monitor for washing machine 2

Use Case

The power monitor should provide a signal as soon as the washing machine is ready. Since the performance curve does not allow a direct reading of this state, the determination follows the following scheme.

image

image

[{"id":"a38195f6.6af8f8","type":"tab","label":"Powermonitor 2","disabled":false,"info":""},{"id":"3ec21cd1.c97d14","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12","payloadType":"num","x":310,"y":180,"wires":[["976ec915.4bbaa8"]]},{"id":"efc74cdf.36d5b","type":"comment","z":"a38195f6.6af8f8","name":"Simulierte Leistungsmessung [W]","info":"","x":370,"y":100,"wires":[]},{"id":"20026de2.eea832","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"8","payloadType":"num","x":310,"y":220,"wires":[["976ec915.4bbaa8"]]},{"id":"61d2a55c.cdf46c","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":310,"y":260,"wires":[["976ec915.4bbaa8"]]},{"id":"984a59b3.9d1998","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":310,"y":300,"wires":[["976ec915.4bbaa8"]]},{"id":"f2519817.9fde88","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"25","payloadType":"num","x":310,"y":140,"wires":[["976ec915.4bbaa8"]]},{"id":"ef4ecb0a.bb3068","type":"inject","z":"a38195f6.6af8f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0.1","payloadType":"num","x":310,"y":340,"wires":[["976ec915.4bbaa8"]]},{"id":"976ec915.4bbaa8","type":"function","z":"a38195f6.6af8f8","name":"WM Power Monitor","func":"// === Custom Settings START ==================\nconst TTS = 'Die Wäsche ist fertig';\nconst thresholdValue = 10.0;\nconst offValue = 0.1;\nconst delayTTS = 120 * 1000;\nconst repeatTTS = 30 * 60 * 1000;\n// === Custom Settings END ====================\n\nlet actPower = msg.payload;\n\nif (actPower <= offValue) {\n node.status({fill:'yellow', shape:'ring', text:'Not Running'});\n context.set('stateRunning', false);\n context.set('stateRepeat', false);\n context.set('intervalRunning', false);\n\n let t1 = context.get('t1'); \n clearTimeout(t1);\n\n let t2 = context.get('t2'); \n clearInterval(t2);\n}\n\nif (actPower > thresholdValue) {\n node.status({fill:'blue', shape:'dot', text:'Running P='+ actPower +'W > threshold'});\n context.set('stateRunning', true);\n context.set('stateRepeat', false);\n context.set('intervalRunning', false);\n\n let t1 = context.get('t1'); \n clearTimeout(t1);\n \n let t2 = context.get('t2'); \n clearInterval(t2);\n}\n\nif (actPower <= thresholdValue && (context.get('stateRunning') && !context.get('stateRepeat'))) {\n node.status({fill:'blue', shape:'ring', text:'Running P='+ actPower +'W < threshold'});\n\n let t1 = setTimeout(function(){\n context.set('stateRunning', false)\n context.set('stateRepeat', true);\n node.status({fill:'green', shape:'ring', text:'Finished P='+ actPower +'W'});\n msg['payload'] = TTS;\n node.send(msg);\n }, delayTTS);\n context.set('t1', t1); \n}\n\nif (actPower <= thresholdValue && (!context.get('stateRunning') && context.get('stateRepeat'))) {\n node.status({fill:'green', shape:'ring', text:'Finished P='+ actPower +'W. Repeat TTS'});\n \n let t1 = context.get('t1'); \n clearTimeout(t1);\n\n if (!context.get('intervalRunning')) {\n context.set('intervalRunning', true);\n \n let t2 = setInterval(function(){\n msg['payload'] = TTS;\n node.send(msg);\n }, repeatTTS);\n context.set('t2', t2); \n }\n}\n\n// node.warn(actPower + ' ' + context.get('stateRunning') + ' ' + context.get('stateRepeat') + ' ' + context.get('intervalRunning'));\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":220,"wires":[["1c7446c9.8c7d79"]]},{"id":"1c7446c9.8c7d79","type":"debug","z":"a38195f6.6af8f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":220,"wires":[]},{"id":"25b47b5e.37ad94","type":"comment","z":"a38195f6.6af8f8","name":"Sende Fertig Signal","info":"","x":1010,"y":220,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment