Advertisement
gocseigabor

Home Assistant - Node-RED flows

Apr 8th, 2021 (edited)
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 6.40 KB | None | 0 0
  1. [{"id":"c41f8255.fef87","type":"tab","label":"AquaShield Relay","disabled":false,"info":""},{"id":"ca595c28.93e14","type":"inject","z":"c41f8255.fef87","name":"","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":60,"wires":[["e97f38d2.a47ca8"]]},{"id":"e97f38d2.a47ca8","type":"redis-command","z":"c41f8255.fef87","server":"65e584de.a0758c","command":"get","name":"","topic":"relay1","params":"{}","paramsType":"json","payloadType":"json","block":false,"x":400,"y":60,"wires":[["9b3eaf63.3784a"]]},{"id":"3c742d17.602622","type":"mqtt out","z":"c41f8255.fef87","name":"","topic":"aquashield/relay/1","qos":"0","retain":"","broker":"8b2d755e.819c78","x":850,"y":60,"wires":[]},{"id":"9c1cec61.0b365","type":"mqtt in","z":"c41f8255.fef87","name":"","topic":"aquashield/relay/1","qos":"0","datatype":"utf8","broker":"8b2d755e.819c78","x":210,"y":140,"wires":[["da4bc0c2.8fe35"]]},{"id":"da4bc0c2.8fe35","type":"function","z":"c41f8255.fef87","name":"transform topic","func":"var newMsg = { topic: 'relay1', payload: msg.payload };\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":140,"wires":[["7bafe67c.762398"]]},{"id":"7bafe67c.762398","type":"redis-command","z":"c41f8255.fef87","server":"65e584de.a0758c","command":"set","name":"","topic":"relay1","params":"[\"relay1\",\"1\"]","paramsType":"json","payloadType":"json","block":false,"x":740,"y":140,"wires":[[]]},{"id":"9b3eaf63.3784a","type":"function","z":"c41f8255.fef87","name":"","func":"var payload = msg.payload;\nvar tmp = '';\nvar AQ_switch_state = flow.get(\"AQ_switch_state\"); \n\nif(msg.payload != AQ_switch_state){\n    flow.set(\"AQ_switch_state\", msg.payload);\n    var newMsg = { topic: 'relay1', payload: msg.payload };\n    //return msg;\n    //node.send(msg);\n    return newMsg;\n    \n} else {\n    return false;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":60,"wires":[["3c742d17.602622"]]},{"id":"52cc1c16.ab5c24","type":"inject","z":"c41f8255.fef87","name":"","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":260,"wires":[["82f1e926.b954c8"]]},{"id":"82f1e926.b954c8","type":"redis-command","z":"c41f8255.fef87","server":"65e584de.a0758c","command":"get","name":"","topic":"relay2","params":"{}","paramsType":"json","payloadType":"json","block":false,"x":400,"y":260,"wires":[["2a6a40c2.b87cc"]]},{"id":"cc1e1438.7af448","type":"mqtt out","z":"c41f8255.fef87","name":"","topic":"aquashield/relay/2","qos":"0","retain":"","broker":"8b2d755e.819c78","x":850,"y":260,"wires":[]},{"id":"44886415.8af42c","type":"mqtt in","z":"c41f8255.fef87","name":"","topic":"aquashield/relay/2","qos":"0","datatype":"utf8","broker":"8b2d755e.819c78","x":210,"y":340,"wires":[["995fd223.fa6cd"]]},{"id":"995fd223.fa6cd","type":"function","z":"c41f8255.fef87","name":"transform topic","func":"var newMsg = { topic: 'relay2', payload: msg.payload };\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":340,"wires":[["d3c4c41c.5274f8"]]},{"id":"d3c4c41c.5274f8","type":"redis-command","z":"c41f8255.fef87","server":"65e584de.a0758c","command":"set","name":"","topic":"relay2","params":"[\"relay2\",\"1\"]","paramsType":"json","payloadType":"json","block":false,"x":740,"y":340,"wires":[[]]},{"id":"2a6a40c2.b87cc","type":"function","z":"c41f8255.fef87","name":"","func":"var payload = msg.payload;\nvar tmp = '';\nvar AQ_switch_state = flow.get(\"AQ_switch_state\"); \n\nif(msg.payload != AQ_switch_state){\n    flow.set(\"AQ_switch_state\", msg.payload);\n    var newMsg = { topic: 'relay1', payload: msg.payload };\n    //return msg;\n    //node.send(msg);\n    return newMsg;\n    \n} else {\n    return false;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":260,"wires":[["cc1e1438.7af448"]]},{"id":"1ca48935.7385e7","type":"tab","label":"AquaShield Sensor","disabled":false,"info":""},{"id":"437e4d23.36be04","type":"inject","z":"1ca48935.7385e7","name":"","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":180,"wires":[["7bf9c8a5.8c96b8"]]},{"id":"6a03d967.962638","type":"mqtt out","z":"1ca48935.7385e7","name":"","topic":"","qos":"0","retain":"","broker":"8b2d755e.819c78","x":830,"y":180,"wires":[]},{"id":"7bf9c8a5.8c96b8","type":"redis-lua-script","z":"1ca48935.7385e7","server":"65e584de.a0758c","name":"","keyval":"0","func":"local sensors = redis.call(\"lrange\", \"sensors\", 0, 10);\nreturn sensors; \n","stored":false,"block":false,"x":420,"y":180,"wires":[["58101562.fca8dc"]]},{"id":"58101562.fca8dc","type":"function","z":"1ca48935.7385e7","name":"","func":"var origmsg = msg;\nvar payload = msg.payload;\nvar tmp = '';\nvar retval = [];\nfor (var i = 0; i < payload.length; i++){\n    tmp = JSON.parse(payload[i]);\n    tmp[\"value\"] = parseFloat(tmp[\"value\"]).toFixed(2);\n    msg.payload = tmp;\n    msg.topic = 'aquashield/sensors/'+tmp[\"sensor\"].replace(/\\s/g,'');\n    node.send(msg);\n    //retval.push(items);\n}\nreturn retval;","outputs":1,"noerr":0,"x":630,"y":180,"wires":[["6a03d967.962638"]]},{"id":"7a024382.28c1ac","type":"tab","label":"AquaShield Level Switch","disabled":false,"info":""},{"id":"cc1aced2.cd97b","type":"inject","z":"7a024382.28c1ac","name":"","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":200,"wires":[["6c98f5ae.ec4d5c"]]},{"id":"6c98f5ae.ec4d5c","type":"redis-command","z":"7a024382.28c1ac","server":"65e584de.a0758c","command":"get","name":"","topic":"input1","params":"{}","paramsType":"json","payloadType":"json","block":false,"x":560,"y":200,"wires":[["85f4964b.680638"]]},{"id":"85f4964b.680638","type":"mqtt out","z":"7a024382.28c1ac","name":"","topic":"aquashield/ls/1","qos":"0","retain":"","broker":"8b2d755e.819c78","x":800,"y":200,"wires":[]},{"id":"65e584de.a0758c","type":"redis-config","name":"AS.local","options":"{\"host\":\"YOURAQUASHIELDDEVICEIP\",\"port\":\"6379\",\"password\":\"\"}","cluster":false,"optionsType":"json"},{"id":"8b2d755e.819c78","type":"mqtt-broker","name":"LocalMQTT","broker":"YOURMQTTIP_SAMEASYOURHOMEASSISTANTIP_IFYOU_USEMQTT_AS_A_HOMEASSISTANT_COMPONENT","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"hass/status","birthQos":"0","birthPayload":"online","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"hass/status","willQos":"0","willPayload":"offline"}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement