Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [{"id":"a21a50b0.b7373","type":"tab","label":"Example","disabled":false,"info":"Example flow for MQTT timer/countdown functionality for Lovelace"},{"id":"82d4cbd3.e84728","type":"change","z":"a21a50b0.b7373","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":80,"wires":[["42ffd735.057fe8"]]},{"id":"7e0a9d3c.c2d054","type":"trigger-state","z":"a21a50b0.b7373","name":"Laundry Off","server":"52fcfb7c.fc8c24","entityid":"input_boolean.washingmachine","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"io60szfcima","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"id":"5w8qkdlp4lq","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"x":70,"y":120,"wires":[["345e8670.0631da","82d4cbd3.e84728","fd57d8ad.e40068"],[]]},{"id":"fd57d8ad.e40068","type":"change","z":"a21a50b0.b7373","name":"Reset Counter","rules":[{"t":"set","p":"reset","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":120,"wires":[["f0c30d1.f0046f"]]},{"id":"258c5c1b.c6cce4","type":"trigger-state","z":"a21a50b0.b7373","name":"Laundry On","server":"52fcfb7c.fc8c24","entityid":"input_boolean.washingmachine","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"i1zlag9oto","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"x":70,"y":180,"wires":[["42ffd735.057fe8"],[]]},{"id":"42ffd735.057fe8","type":"looptimer","z":"a21a50b0.b7373","duration":"1","units":"Second","maxloops":"10800","maxtimeout":"4","maxtimeoutunits":"Hour","name":"","x":240,"y":180,"wires":[["f0c30d1.f0046f"],[]]},{"id":"f0c30d1.f0046f","type":"counter","z":"a21a50b0.b7373","name":"","init":"0","step":"1","lower":"","upper":"10800","mode":"increment","outputs":"1","x":400,"y":180,"wires":[["c55eb711.958d58"]]},{"id":"c55eb711.958d58","type":"function","z":"a21a50b0.b7373","name":"Integer to HH:MM:SS","func":"var sec_num=msg.count;\nvar hours=Math.floor(sec_num/3600)\nvar minutes=Math.floor((sec_num-(hours*3600))/60)\nvar seconds=Math.floor((sec_num-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nvar msg = {payload:hours+':'+minutes+':'+seconds};\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":180,"wires":[["6257f9.ca55c808"]]},{"id":"cb9a3c03.c6237","type":"inject","z":"a21a50b0.b7373","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":240,"wires":[["c859f38d.72a5a","fd57d8ad.e40068"]]},{"id":"c859f38d.72a5a","type":"api-current-state","z":"a21a50b0.b7373","name":"Washing Halt On","server":"52fcfb7c.fc8c24","halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"input_boolean.washingmachine","state_type":"str","outputs":2,"x":290,"y":240,"wires":[["345e8670.0631da"],[]]},{"id":"345e8670.0631da","type":"change","z":"a21a50b0.b7373","name":"00:00:00","rules":[{"t":"set","p":"payload","pt":"msg","to":"00:00:00","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":240,"wires":[["6257f9.ca55c808"]]},{"id":"6257f9.ca55c808","type":"mqtt out","z":"a21a50b0.b7373","name":"washing/ontime","topic":"washing/ontime","qos":"","retain":"true","broker":"1cd28398.aba36c","x":660,"y":240,"wires":[]},{"id":"108b8b16.b10665","type":"function","z":"a21a50b0.b7373","name":"Integer to Countdown HH:MM:SS","func":"var remaining=600-msg.count;\nvar hours=Math.floor(remaining/3600)\nvar minutes=Math.floor((remaining-(hours*3600))/60)\nvar seconds=Math.floor((remaining-(hours*3600)-(minutes*60)))\n if (hours < 10) {hours = \"0\"+hours;}\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nvar msg = {payload:hours+':'+minutes+':'+seconds};\nreturn msg;","outputs":1,"noerr":0,"x":640,"y":100,"wires":[[]]},{"id":"f75196b3.43ba78","type":"function","z":"a21a50b0.b7373","name":"Integer to Countdown MM:SS","func":"var remaining=600-msg.count;\nvar minutes=Math.floor(remaining/60)\nvar seconds=Math.floor(remaining-(minutes*60))\n if (minutes < 10) {minutes = \"0\"+minutes;}\n if (seconds < 10) {seconds = \"0\"+seconds;}\nvar msg = {payload:minutes+':'+seconds};\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":140,"wires":[[]]},{"id":"52fcfb7c.fc8c24","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open"},{"id":"1cd28398.aba36c","type":"mqtt-broker","z":"","name":"Mosquitto","broker":"192.168.1.27","port":"1883","tls":"","clientid":"NodeRed","usetls":false,"compatmode":true,"keepalive":"300","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Advertisement
Add Comment
Please, Sign In to add comment