I think I have it all working just like I’d hoped. Obviously still some testing to do, but so far, all good!
Have a look and let me know what you think. I’m open to any suggestions!
1 - Pump Stopped Cycling
[{"id":"8ea11c5c.0029b","type":"interval-length","z":"c4aae7e8.6cbbe8","format":"mills","bytopic":false,"minimum":"","maximum":"","window":"","timeout":false,"msgTimeout":"","minimumunit":"msecs","maximumunit":"msecs","windowunit":"msecs","msgTimeoutUnit":"msecs","reset":false,"startup":false,"msgField":"payload","timestampField":"timestamp","repeatTimeout":false,"name":"Off to Off interval","x":310,"y":160,"wires":[["e1100796.718d78"],[]]},{"id":"cd51e7cf.dbf958","type":"smooth","z":"c4aae7e8.6cbbe8","name":"Average Cycles","property":"payload","action":"mean","count":"5","round":"1","mult":"single","reduce":false,"x":360,"y":220,"wires":[["f5703d34.af148"]]},{"id":"f5703d34.af148","type":"calculator","z":"c4aae7e8.6cbbe8","name":"Multiply x2","inputMsgField":"payload","outputMsgField":"payload","operation":"mult","constant":"2","x":550,"y":220,"wires":[["1e4edcfe.cbe083"]]},{"id":"1e4edcfe.cbe083","type":"function","z":"c4aae7e8.6cbbe8","name":"Set avgcyclex2","func":"flow.set(\"avgcyclex2\", msg.payload);\nreturn msg;","outputs":0,"noerr":0,"x":740,"y":220,"wires":[]},{"id":"efea01d8.debb5","type":"server-state-changed","z":"c4aae7e8.6cbbe8","name":"NP Amp Draw","server":"303f7d80.f295e2","version":1,"entityidfilter":"sensor.north_pump","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"0","halt_if_type":"num","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":90,"y":120,"wires":[["227a44a8.2d818c"],["60c3fc76.cdf884","8ea11c5c.0029b"]]},{"id":"7fe6879b.1d5a68","type":"function","z":"c4aae7e8.6cbbe8","name":"Avg Cycle Timer X2","func":"{var timeouttime = flow.get('avgcyclex2');\nmsg.timeout = timeouttime;\nreturn msg;}","outputs":1,"noerr":0,"x":470,"y":100,"wires":[["e5760d6.5799ff"]]},{"id":"e5760d6.5799ff","type":"mytimeout","z":"c4aae7e8.6cbbe8","name":"","outtopic":"","outsafe":"","outwarning":"Warning","outunsafe":"off","warning":"1","timer":"1","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":490,"y":40,"wires":[["1c9ecf92.b849b"],[]]},{"id":"e1100796.718d78","type":"calculator","z":"c4aae7e8.6cbbe8","name":"ms to sec","inputMsgField":"payload","outputMsgField":"payload","operation":"div","constant":"1000","x":540,"y":160,"wires":[["cd51e7cf.dbf958"]]},{"id":"60c3fc76.cdf884","type":"trigger","z":"c4aae7e8.6cbbe8","op1":"","op2":"avgcyclex2","op1type":"nul","op2type":"flow","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Delay","x":290,"y":100,"wires":[["7fe6879b.1d5a68"]]},{"id":"227a44a8.2d818c","type":"change","z":"c4aae7e8.6cbbe8","name":"Pass \"stop\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":40,"wires":[["e5760d6.5799ff"]]},{"id":"1c9ecf92.b849b","type":"switch","z":"c4aae7e8.6cbbe8","name":"Only Pass \"off\"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":700,"y":40,"wires":[["b9ba0022.69271"]]},{"id":"b9ba0022.69271","type":"debug","z":"c4aae7e8.6cbbe8","name":"Send Telegram Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":780,"y":100,"wires":[]},{"id":"303f7d80.f295e2","type":"server","z":"","name":"Home Assistant"}]
2 - Pumping longer than 60 seconds (I could use above code to create a sliding timer for this, but prefer a simpler solution).
[{"id":"be7114bd.76c338","type":"tab","label":"NP_Running Too Long","disabled":false,"info":""},{"id":"7e575bd0.f0c304","type":"api-call-service","z":"be7114bd.76c338","name":"Pump Running Too Long","server":"303f7d80.f295e2","version":1,"debugenabled":false,"service_domain":"telegram_bot","service":"send_message","entityId":"disable_notification=false","data":"{\"message\":\"North Pump running longer than 60 seconds\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":490,"y":120,"wires":[[]]},{"id":"1942c7cd.dfc758","type":"stoptimer","z":"be7114bd.76c338","duration":"60","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":290,"y":60,"wires":[["7e575bd0.f0c304"],[]]},{"id":"ff892da7.516d5","type":"server-state-changed","z":"be7114bd.76c338","name":"NP State","server":"303f7d80.f295e2","version":1,"entityidfilter":"sensor.north_pump","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":".1","halt_if_type":"num","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":true,"x":60,"y":80,"wires":[["1942c7cd.dfc758"],["aa28f211.f7e7d"]]},{"id":"aa28f211.f7e7d","type":"change","z":"be7114bd.76c338","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":140,"wires":[["1942c7cd.dfc758"]]},{"id":"303f7d80.f295e2","type":"server","z":"","name":"Home Assistant"}]
3 - Sonoff Switched Off:
[{"id":"13907665.3c8e5a","type":"tab","label":"NP_Sonoff State","disabled":false,"info":""},{"id":"cb26cd45.7476a","type":"stoptimer","z":"13907665.3c8e5a","duration":"60","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":330,"y":60,"wires":[["c4a6662e.74e088"],[]]},{"id":"7fd66ad6.c111b4","type":"change","z":"13907665.3c8e5a","name":"Switch On, Stop Timer","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":120,"wires":[["cb26cd45.7476a"]]},{"id":"c4a6662e.74e088","type":"api-call-service","z":"13907665.3c8e5a","name":"Telegram NP Off","server":"303f7d80.f295e2","version":1,"debugenabled":false,"service_domain":"telegram_bot","service":"send_message","entityId":"disable_notification=false","data":"{\"message\":\"North Pump Switch Off\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":520,"y":60,"wires":[[]]},{"id":"e4ba18f3.ba7028","type":"server-state-changed","z":"13907665.3c8e5a","name":"NP Switch State","server":"303f7d80.f295e2","version":1,"entityidfilter":"switch.north_pump_switch","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":80,"y":40,"wires":[["cb26cd45.7476a"],["7fd66ad6.c111b4"]]},{"id":"303f7d80.f295e2","type":"server","z":"","name":"Home Assistant"}]
3b - Sonoff network Down:
[{"id":"4016cd65.074404","type":"tab","label":"NP_Sonoff Network","disabled":false,"info":""},{"id":"55d1e40a.e7d7ec","type":"ping","z":"4016cd65.074404","name":"Ping North Pump Sonoff","host":"` [ `192.168.0.96` ](https://192.168.0.96/) `","timer":"5","x":110,"y":40,"wires":[["88bb251.b7777d8"]],"outputLabels":["false"]},{"id":"88bb251.b7777d8","type":"switch","z":"4016cd65.074404","name":"Ping State","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":100,"wires":[["693f5c69.f26ec4"],["9dd60157.af88e"]]},{"id":"9dd60157.af88e","type":"change","z":"4016cd65.074404","name":"Ping UP --> STOP","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":160,"wires":[["693f5c69.f26ec4"]]},{"id":"9c845ff5.f80e8","type":"api-call-service","z":"4016cd65.074404","name":"","server":"303f7d80.f295e2","version":1,"debugenabled":false,"service_domain":"telegram_bot","service":"send_message","entityId":"disable_notification=false","data":"{\"message\":\"North Pump Sonoff Down\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":600,"y":140,"wires":[[]]},{"id":"693f5c69.f26ec4","type":"stoptimer","z":"4016cd65.074404","duration":"60","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":450,"y":80,"wires":[["9c845ff5.f80e8"],[]]},{"id":"303f7d80.f295e2","type":"server","z":"","name":"Home Assistant"}]