+[{"id":"3fd1fcdf.36063c","type":"subflow","name":"Light Response","info":"","category":"HUE v2","in":[{"x":100,"y":380,"wires":[{"id":"88eac1bd4d2ab5b7"}]}],"out":[{"x":1020,"y":380,"wires":[{"id":"3b007fc2.9f0448","port":0},{"id":"a5f5c653.282a7","port":0}]}],"env":[{"name":"light_ID","type":"str","value":"replace with discovered Lamp / Group ID"}],"meta":{},"color":"#C0DEED","icon":"node-red/light.svg"},{"id":"edb5df72.69def8","type":"rbe","z":"3fd1fcdf.36063c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":730,"y":300,"wires":[["3b007fc2.9f0448"]]},{"id":"3b007fc2.9f0448","type":"switch","z":"3fd1fcdf.36063c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":300,"wires":[[]]},{"id":"6eab42b7.86eab4","type":"change","z":"3fd1fcdf.36063c","name":"False","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":260,"wires":[["dc3e64b5.ab74e8"]]},{"id":"dc3e64b5.ab74e8","type":"delay","z":"3fd1fcdf.36063c","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":850,"y":260,"wires":[["edb5df72.69def8"]]},{"id":"bc246720.a972d","type":"change","z":"3fd1fcdf.36063c","name":"True","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":340,"wires":[["edb5df72.69def8"]]},{"id":"3581683f.6598d","type":"delay","z":"3fd1fcdf.36063c","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":850,"y":500,"wires":[["d6d75391.dccac8"]]},{"id":"d6d75391.dccac8","type":"rbe","z":"3fd1fcdf.36063c","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":730,"y":460,"wires":[["a5f5c653.282a7"]]},{"id":"6bdd0583.7c75e4","type":"change","z":"3fd1fcdf.36063c","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":420,"wires":[["d6d75391.dccac8"]]},{"id":"cf0d42b2.ad37e8","type":"change","z":"3fd1fcdf.36063c","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":500,"wires":[["3581683f.6598d"]]},{"id":"a5f5c653.282a7","type":"switch","z":"3fd1fcdf.36063c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":460,"wires":[[]]},{"id":"9fc6225e.6421c8","type":"switch","z":"3fd1fcdf.36063c","name":"true / false","property":"payload.data.0.on.on","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":380,"wires":[["bc246720.a972d","6eab42b7.86eab4"],["6bdd0583.7c75e4","cf0d42b2.ad37e8"]]},{"id":"88eac1bd4d2ab5b7","type":"switch","z":"3fd1fcdf.36063c","name":"light / grouped_light ID","property":"payload.data.0.id","propertyType":"msg","rules":[{"t":"cont","v":"light_ID","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":260,"y":380,"wires":[["9fc6225e.6421c8"]]},{"id":"3b0871a1c702fcf9","type":"tab","label":"Toggle example ","disabled":false,"info":"","env":[]},{"id":"a33a38011820efd8","type":"function","z":"3b0871a1c702fcf9","name":"On/Off","func":"//VARIABLE\nlet light = {\n state: global.get(\"light1\")\n}\n// ON\nif (\n light.state === false\n )\n{\n return [msg, null];\n}\n// OFF\nif (\n light.state === true\n )\n{\n return [null, msg]\n} \n ","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":540,"wires":[["054e8b86eac5722a"],["7c5541462c01a874"]]},{"id":"2264c299e6f445e5","type":"change","z":"3b0871a1c702fcf9","name":"light1","rules":[{"t":"set","p":"light1","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":220,"wires":[[]]},{"id":"40fe4b83ab14c00c","type":"subflow:3fd1fcdf.36063c","z":"3b0871a1c702fcf9","name":"Light","env":[{"name":"light_ID","value":"Add your ID here","type":"str"}],"x":370,"y":220,"wires":[["2264c299e6f445e5"]]},{"id":"dde1fcbd70a56a29","type":"inject","z":"3b0871a1c702fcf9","name":"Restart","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":140,"y":120,"wires":[["ba55a125578150d5"]]},{"id":"ba55a125578150d5","type":"change","z":"3b0871a1c702fcf9","name":"Variable ","rules":[{"t":"set","p":"light1","pt":"global","to":"false","tot":"bool"},{"t":"set","p":"light2","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":120,"wires":[[]]},{"id":"3349b1febcc012d7","type":"inject","z":"3b0871a1c702fcf9","name":"Your Switch","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":540,"wires":[["a33a38011820efd8"]]},{"id":"c14caabf9f0952d2","type":"link in","z":"3b0871a1c702fcf9","name":"Connect to Event Stream","links":[],"x":170,"y":220,"wires":[["40fe4b83ab14c00c"]],"l":true},{"id":"054e8b86eac5722a","type":"change","z":"3b0871a1c702fcf9","name":"Light On","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Add your Light ID here","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dynamics\":{\"duration\":1000}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":520,"wires":[["8da70e30f15aeb3f","0cf9beb06e47cd2b"]]},{"id":"7c5541462c01a874","type":"change","z":"3b0871a1c702fcf9","name":"Light Off","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Add your Light ID here","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":false},\"dynamics\":{\"duration\":1000}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":560,"wires":[["8da70e30f15aeb3f","a178def84514b559"]]},{"id":"8da70e30f15aeb3f","type":"link out","z":"3b0871a1c702fcf9","name":"Connect to Header Node for Http request","mode":"link","links":[],"x":800,"y":540,"wires":[],"l":true},{"id":"0cf9beb06e47cd2b","type":"debug","z":"3b0871a1c702fcf9","name":"On","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":500,"wires":[]},{"id":"a178def84514b559","type":"debug","z":"3b0871a1c702fcf9","name":"Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":580,"wires":[]},{"id":"ebbd29639c2b17a7","type":"inject","z":"3b0871a1c702fcf9","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":230,"y":340,"wires":[["2264c299e6f445e5"]]},{"id":"79a0045257203dc2","type":"inject","z":"3b0871a1c702fcf9","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":230,"y":380,"wires":[["2264c299e6f445e5"]]},{"id":"e6a18204c90be438","type":"comment","z":"3b0871a1c702fcf9","name":"for testing","info":"","x":220,"y":300,"wires":[]},{"id":"b963d18207d84cd3","type":"comment","z":"3b0871a1c702fcf9","name":"DOUBLE CLICK","info":"This will set the variables to false on \nNodeRed restart. cause they are memory\nstored and get lost. \n\nyou need to add all your individual variable\nfor light/groups here","x":160,"y":80,"wires":[]},{"id":"4e2937742d14568e","type":"comment","z":"3b0871a1c702fcf9","name":"DOUBLE CLICK","info":"you need to use a individual variable for\neach light / group. copy this and change the\nvariable name. \n\ni modified my light receiver a bit, cause \ni always need true/false. you can use this\none, or that comes with the flow.\n\nadd your light / group ID inside that \nyou want to trigger","x":440,"y":180,"wires":[]},{"id":"87b73e85ef740e45","type":"comment","z":"3b0871a1c702fcf9","name":"DOUBLE CLICK","info":"connect this to your switch, the function \nwill ask for the global variable.\n\nthe variable get changed by the light state\n\nif the light is on, it will use second \noutput to the change node. \nif your light is off, it use the first output\nto the change node. \n\nin the change node use the code that you\nneed, i just added a simple on/off with\n1 second transition.\n\nThis works for lights and groups\n\nyou need to replace the var in the function\nnode for individual lights. (light1, lights2) \n","x":360,"y":480,"wires":[]}]
0 commit comments