Hi so i added a lot of sonoff mini devices running tasmota on my house to control the lights, and i wanted to use a configurable timeout for each light with a enable switch and that you are able to control everything from the dashboard i have something working but is quite a lot of nodes, my question is anyone has a simpler solution or is there a way to make this into a couple of blocks also, like make my own block that has all the nodes inside, with my testings so far its working, also i am using mosquitto to save the last time used for when my pi restarts
This is the flow code:
[{"id":"98eff4a9.2e2b08","type":"tab","label":"Timeout","disabled":false,"info":""},{"id":"4a406144.cd8a2","type":"ui_switch","z":"98eff4a9.2e2b08","name":"","label":"Sonoff MiniTest","tooltip":"","group":"cf610d02.525a3","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":320,"y":40,"wires":[["dea50c3b.5b4a5"]]},{"id":"4c58694a.f5d3c8","type":"mqtt in","z":"98eff4a9.2e2b08","name":"","topic":"stat/sonoffT/POWER","qos":"1","datatype":"auto","broker":"4d34c726.f79428","x":110,"y":40,"wires":[["4a406144.cd8a2","9b6c4bfb.4fd0b8"]]},{"id":"2bece2c2.0897ce","type":"ui_switch","z":"98eff4a9.2e2b08","name":"","label":"SonoffT","tooltip":"","group":"988a8154.4bc07","order":1,"width":"4","height":"1","passthru":true,"decouple":"false","topic":"enable","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":240,"y":100,"wires":[["9b6c4bfb.4fd0b8"]]},{"id":"dea50c3b.5b4a5","type":"mqtt out","z":"98eff4a9.2e2b08","name":"","topic":"stat/sonoffT/POWER","qos":"2","retain":"true","broker":"4d34c726.f79428","x":540,"y":40,"wires":[]},{"id":"54228a72.62c784","type":"delay","z":"98eff4a9.2e2b08","name":"","pauseType":"delayv","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":580,"y":100,"wires":[["dea50c3b.5b4a5","a9314a9e.136528"]]},{"id":"9330e0d4.e7c9d","type":"ui_text_input","z":"98eff4a9.2e2b08","name":"","label":"Tiempo Min","tooltip":"0-120 Min","group":"988a8154.4bc07","order":2,"width":"2","height":"1","passthru":true,"mode":"number","delay":"1","topic":"delay","x":470,"y":160,"wires":[["9b6c4bfb.4fd0b8","9d04ad3.610a95"]]},{"id":"9b6c4bfb.4fd0b8","type":"function","z":"98eff4a9.2e2b08","name":"IF","func":"if (msg.topic == \"delay\") {\n if (msg.payload >=1 && msg.payload<120)\n {context.delay=msg.payload*60000; \n }\n else{context.delay=5*60000;\n }\n return null;\n}\n\nif (msg.topic == \"enable\") {\n\tcontext.state = msg.payload;\n\treturn null;\n}\n\nif (msg.payload==\"ON\"){\n if (context.state==1){\n msg.payload=\"OFF\";\n msg.delay=context.delay;\n return msg;}\n }\nelse\n return null;","outputs":1,"noerr":0,"x":390,"y":100,"wires":[["54228a72.62c784","a9314a9e.136528"]]},{"id":"39b76e89.21f2c2","type":"inject","z":"98eff4a9.2e2b08","name":"ONS","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":"0.1","x":90,"y":100,"wires":[["2bece2c2.0897ce","60fbcb4e.0be464"]]},{"id":"311d78.29111288","type":"mqtt in","z":"98eff4a9.2e2b08","name":"","topic":"delay1","qos":"1","datatype":"auto","broker":"4d34c726.f79428","x":70,"y":160,"wires":[["60fbcb4e.0be464"]]},{"id":"9d04ad3.610a95","type":"mqtt out","z":"98eff4a9.2e2b08","name":"","topic":"delay1","qos":"1","retain":"true","broker":"4d34c726.f79428","x":610,"y":160,"wires":[]},{"id":"3ff3ead4.3bdbb6","type":"function","z":"98eff4a9.2e2b08","name":"","func":"msg.payload = Number(msg.payload);\nmsg.topic = \"delay\";\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":160,"wires":[["9330e0d4.e7c9d"]]},{"id":"60fbcb4e.0be464","type":"trigger","z":"98eff4a9.2e2b08","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"units":"ms","reset":"true","bytopic":"all","name":"T&B","x":210,"y":160,"wires":[["3ff3ead4.3bdbb6"]]},{"id":"a9314a9e.136528","type":"debug","z":"98eff4a9.2e2b08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":220,"wires":[]},{"id":"cf610d02.525a3","type":"ui_group","z":"","name":"Luces","tab":"6f8b1d8b.49e0b4","order":1,"disp":true,"width":"6","collapse":false},{"id":"4d34c726.f79428","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"JuanC","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"988a8154.4bc07","type":"ui_group","z":"","name":"Temporizadores","tab":"6f8b1d8b.49e0b4","order":2,"disp":true,"width":"6","collapse":false},{"id":"6f8b1d8b.49e0b4","type":"ui_tab","z":"","name":"Control Maestro","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
```[Timeout Flow.json|attachment](upload://4aVGCPmLYuad0juCJyp144IgFZB.json) (4.4 KB)