Advertisement
Guest User

Node red project

a guest
Dec 27th, 2022
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 14.47 KB | None | 0 0
  1. [{"id":"272ec6fa.1c208a","type":"inject","z":"9522bbe913e8d405","name":"next","props":[{"p":"command","v":"next","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":960,"wires":[["ad17b0b6.40d5c"]]},{"id":"7f911100.72e77","type":"inject","z":"9522bbe913e8d405","name":"previous","props":[{"p":"command","v":"previous","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1000,"wires":[["ad17b0b6.40d5c"]]},{"id":"56f6521d.3c5a5c","type":"inject","z":"9522bbe913e8d405","name":"set default","props":[{"p":"command","v":"set","vt":"str"},{"p":"scene","v":"scene.camera_default","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":1080,"wires":[["ad17b0b6.40d5c"]]},{"id":"8b2d9945.0a7068","type":"inject","z":"9522bbe913e8d405","name":"set 0","props":[{"p":"command","v":"set","vt":"str"},{"p":"scene","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":1040,"wires":[["ad17b0b6.40d5c"]]},{"id":"cc1d9423.c045c8","type":"scene-in","z":"9522bbe913e8d405","name":"default camera","scene":"scene.camera_default","active":true,"x":160,"y":1140,"wires":[["ffa29e33ae364391"]]},{"id":"b88b51ff.be731","type":"scene-in","z":"9522bbe913e8d405","name":"relax camera","scene":"scene.camera_relax","active":true,"x":150,"y":1180,"wires":[["ffa29e33ae364391"]]},{"id":"ad17b0b6.40d5c","type":"scene-selector","z":"9522bbe913e8d405","name":"","scenes":["scene.camera_relax","scene.camera_default"],"wrapAround":true,"changedOutputOnly":false,"x":420,"y":1020,"wires":[]},{"id":"ffa29e33ae364391","type":"api-call-service","z":"9522bbe913e8d405","name":"","server":"5f04c7c3.35aa98","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{scene}}"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":1160,"wires":[[]]},{"id":"48256c6ac67b077d","type":"scene-in","z":"9522bbe913e8d405","name":"default cucina","scene":"scene.cucina_default","active":true,"x":150,"y":1220,"wires":[["ffa29e33ae364391"]]},{"id":"4f55deb19320cf1d","type":"scene-in","z":"9522bbe913e8d405","name":"relax cucina","scene":"scene.cucina_relax","active":true,"x":150,"y":1260,"wires":[["ffa29e33ae364391"]]},{"id":"675bc10c20b620de","type":"scene-in","z":"9522bbe913e8d405","name":"default salotto","scene":"scene.salotto_default","active":true,"x":150,"y":1300,"wires":[["ffa29e33ae364391"]]},{"id":"4ea0c739fd0c22e1","type":"scene-in","z":"9522bbe913e8d405","name":"relax salotto","scene":"scene.salotto_relax","active":true,"x":150,"y":1340,"wires":[["ffa29e33ae364391"]]},{"id":"7c19e9cd2fe7e8d3","type":"function","z":"9522bbe913e8d405","name":"Switch case","func":"var inputSwitch = msg.topic;\nvar entityID = \"default\";\nvar actionButton = \"default\"\nvar select = true; // true for standard action, false for scene activation\ninputSwitch = inputSwitch.substring(inputSwitch.indexOf(\"/\")+1, inputSwitch.indexOf(\"/\",8));\nswitch(inputSwitch) {\n    case \"tasmota_bagno\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luce_3cr\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luce_3cr\", \"action\": msg.payload.Button1.Action };\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            return null;\n            //to be defined\n        }\n        if (msg.payload.Button3 !== undefined) {\n            entityID = \"light.luci_camera\";\n            actionButton = msg.payload.Button3.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luci_camera\", \"action\": msg.payload.Button3.Action };\n            break;\n        }\n        if (msg.payload.Button4 !== undefined) {\n            entityID = \"light.luci_salotto\";\n            actionButton = msg.payload.Button4.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luci_salotto\", \"action\": msg.payload.Button4.Action };\n            break;\n        }\n        node.warn(\"tasmota_bagno:something went wrong\");\n        break;\n    case \"tasmota_salotto\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luci_salotto\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luci_salotto\", \"action\": msg.payload.Button1.Action };\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            entityID = \"light.luci_salotto\";\n            actionButton = msg.payload.Button2.Action;\n            select = false;\n            //msg = { \"entity_id\": \"scene.salotto_relax\", \"action\": msg.payload.Button2.Action }; \n            break;\n        }\n        node.warn(\"tasmota_salotto:something went wrong\");\n        break;\n    case \"tasmota_camera\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luci_camera\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luci_camera\", \"action\": msg.payload.Button1.Action};\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break; \n        }\n        if (msg.payload.Button2 !== undefined) {\n            entityID = \"light.luci_camera\";\n            actionButton = msg.payload.Button2.Action;\n            select = false;\n            //msg = { \"entity_id\": \"scene.camera_relax\", \"action\": msg.payload.Button2.Action };\n            break; \n        }\n        node.warn(\"tasmota_camera:something went wrong\");\n        break;\n    case \"tasmota_cucina\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luci_cucina\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luci_cucina\", \"action\": msg.payload.Button1.Action };\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            entityID = \"light.luci_cucina\";\n            actionButton = msg.payload.Button2.Action;\n            select = false;\n            //msg = { \"entity_id\": \"scene.cucina_relax\", \"action\": msg.payload.Button2.Action };\n            break;\n        }\n        node.warn(\"tasmota_cucina:something went wrong\");\n        break;\n    case \"tasmota_bagno_servizi\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luce_2cr\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luce_2cr\", \"action\": msg.payload.Button1.Action };\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            entityID = \"light.bagno_servizi\";\n            actionButton = msg.payload.Button2.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.bagno_servizi\", \"action\": msg.payload.Button2.Action };\n            break;\n        }\n        node.warn(\"tasmota_bagno_servizi:something went wrong\");\n        break;\n    case \"tasmota_wc\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luce_wc\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luce_wc\", \"action\": msg.payload.Button1.Action };\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            return null;\n            //to be defined\n        }\n        node.warn(\"tasmota_wc:something went wrong\");\n        break;\n    case \"tasmota_ingresso\":\n        if (msg.payload.Button1 !== undefined) {\n            entityID = \"light.luce_1cr\";\n            actionButton = msg.payload.Button1.Action;\n            select = true;\n            //msg = { \"entity_id\": \"light.luce_1cr\", \"action\": msg.payload.Button1.Action };\n            //msg[\"entity_id\"] = \"light.luce_1cm\";\n            break;\n        }\n        if (msg.payload.Button2 !== undefined) {\n            return null;\n            //to be defined\n        }\n        node.warn(\"tasmota_ingresso:something went wrong\");\n        break;\n}\nreturn msg =\n{\n    \"payload\": {\n        \"action\": actionButton,\n        \"typeofaction\": select,\n        \"data\": {\n            \"entity_id\": entityID\n        }\n    }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":840,"wires":[["23d72e38bc3254d4"]]},{"id":"9ac32c919af3e992","type":"debug","z":"9522bbe913e8d405","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1670,"y":840,"wires":[]},{"id":"c6b1df4107e8925f","type":"api-call-service","z":"9522bbe913e8d405","name":"","server":"5f04c7c3.35aa98","version":5,"debugenabled":false,"domain":"light","service":"turn_{{execute}}","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1240,"y":660,"wires":[["9ac32c919af3e992"]]},{"id":"b2311ffe41a0477c","type":"switch","z":"9522bbe913e8d405","name":"ACTION","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"SINGLE","vt":"str"},{"t":"eq","v":"DOUBLE","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":700,"y":840,"wires":[["502225064a649270"],["20d9d55fe7568a7f"]]},{"id":"20d9d55fe7568a7f","type":"function","z":"9522bbe913e8d405","name":"choose DOUBLE","func":"if(msg.data.state==\"on\") {msg.execute = \"on\";return msg;}\n  else {return null } ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":900,"wires":[["5277d15ee9903756"]]},{"id":"502225064a649270","type":"function","z":"9522bbe913e8d405","name":"choose SINGLE","func":"if(msg.data.state==\"on\") {msg.execute = \"off\";} \n    else {msg.execute = \"on\";}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":780,"wires":[["a720d621d7d17012"]]},{"id":"5277d15ee9903756","type":"function","z":"9522bbe913e8d405","name":"Dimmer","func":"var check = msg.data.attributes.brightness;\nnode.warn(\"brightness: \" + check);\nif (check !== 255)\n\n    return msg =\n    {\n        \"execute\": msg.execute,\n        \"payload\": {\n            \"data\": {\n                \"entity_id\": msg.payload.data.entity_id,\n                \"brightness_step\": 64\n                //\"rgb_color\": [255,200,255]\n            }\n        }\n    }\nelse return msg =\n{\n    \"execute\": msg.execute,\n    \"payload\": {\n        \"data\": {\n            \"entity_id\": msg.payload.data.entity_id,\n            \"brightness\": 64\n            //\"rgb_color\": [255,200,255]\n        }\n    }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1020,"y":960,"wires":[["c6b1df4107e8925f"]]},{"id":"a720d621d7d17012","type":"switch","z":"9522bbe913e8d405","name":"ACTION TYPE","property":"payload.typeofaction","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":1020,"y":720,"wires":[["c6b1df4107e8925f"],["72544aadf8be02f4"]]},{"id":"72544aadf8be02f4","type":"function","z":"9522bbe913e8d405","name":"Next scene","func":"msg.command=\"next\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":800,"wires":[["1a6fa74afc455d30","9ac32c919af3e992"]]},{"id":"a017e3924d42559f","type":"scene-selector","z":"9522bbe913e8d405","name":"","scenes":["scene.camera_relax","scene.camera_default"],"wrapAround":true,"changedOutputOnly":false,"x":1400,"y":900,"wires":[]},{"id":"a0f7aff9b77e396f","type":"scene-selector","z":"9522bbe913e8d405","name":"","scenes":["scene.cucina_default","scene.cucina_relax"],"wrapAround":true,"changedOutputOnly":false,"x":1540,"y":960,"wires":[]},{"id":"1a6fa74afc455d30","type":"switch","z":"9522bbe913e8d405","name":"Room","property":"payload.data.entity_id","propertyType":"msg","rules":[{"t":"cont","v":"camera","vt":"str"},{"t":"cont","v":"cucina","vt":"str"},{"t":"cont","v":"salotto","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1350,"y":960,"wires":[["a017e3924d42559f"],["a0f7aff9b77e396f"],["bcb11ffeca45ba77"]]},{"id":"bcb11ffeca45ba77","type":"scene-selector","z":"9522bbe913e8d405","name":"","scenes":["scene.salotto_default","scene.salotto_relax"],"wrapAround":true,"changedOutputOnly":false,"x":1400,"y":1020,"wires":[]},{"id":"23d72e38bc3254d4","type":"api-current-state","z":"9522bbe913e8d405","name":"Check status light","server":"5f04c7c3.35aa98","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"{{payload.data.entity_id}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":840,"wires":[["b2311ffe41a0477c"]]},{"id":"7b2a2a654a1388b5","type":"mqtt in","z":"9522bbe913e8d405","name":"","topic":"stat/+/RESULT","qos":"2","datatype":"auto-detect","broker":"a3fb535a1424f3bc","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":840,"wires":[["7c19e9cd2fe7e8d3"]]},{"id":"ca5542ceceb3c96a","type":"function","z":"9522bbe913e8d405","name":"Switch","func":"var inputSwitch = msg.payload.action;\nswitch (inputSwitch) {\n    case \"SINGLE\":\n        if (msg.data.state == \"on\") { msg.execute = \"off\" }\n        else { msg.execute = \"on\" }\n    break;\n    case \"DOUBLE\":\n        if (msg.data.state == \"on\") { msg.execute = \"on\"; return msg; }\n        else { return null }\n    break;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":960,"wires":[[]]},{"id":"5f04c7c3.35aa98","type":"server","name":"Home Assistant","addon":true},{"id":"a3fb535a1424f3bc","type":"mqtt-broker","name":"Mqtt Broker","broker":"10.10.10.181","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement