Controlling IKEA Tradfri bulb

I put some examples together how to control IKEA bulb from Node Red using the node-red-contrib-tradfri node. This shows some of the basics of controlling bulb, brightness, color and also some of the complicated cases like getting the Tradfri devices and control them dynamically.

You might want to look at my video explaining the details of this flow: https://youtu.be/075zTnrIp1Y

[{"id":"eb97cc51.da1ca","type":"tab","label":"Tradfri"},{"id":"9c85cee1.c74df","type":"change","z":"eb97cc51.da1ca","name":"Turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":820,"wires":[["b0928cb6.3f801"]]},{"id":"e7290df7.f6f36","type":"change","z":"eb97cc51.da1ca","name":"Set brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":255}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1140,"wires":[["107ebd2e.41eac3"]]},{"id":"3585b9c2.ca7166","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":880,"wires":[["8ef23ea5.1b0bc"]]},{"id":"a0b961ee.1e86e","type":"switch","z":"eb97cc51.da1ca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","outputs":2,"x":524.0000038146973,"y":1009.0000019073486,"wires":[["41470272.1a4fdc"],["273c90ef.2c7fc"]]},{"id":"41470272.1a4fdc","type":"change","z":"eb97cc51.da1ca","name":"Turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690.0000038146973,"y":988.0000019073486,"wires":[["d3d190e1.bb0d"]]},{"id":"273c90ef.2c7fc","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690.0000038146973,"y":1027.0000019073486,"wires":[["d3d190e1.bb0d"]]},{"id":"66ec280.ceab9d8","type":"function","z":"eb97cc51.da1ca","name":"All lights off","func":"var output = [];\n\n// loop through the groups\nfor (var i=0; i<msg.payload.length; i++) {\n    // loop through each bulb in the group\n    for (var j=0; j<msg.payload[i].devices.length; j++) {\n        if (msg.payload[i].devices[j].type.indexOf(\"bulb\")!==-1) {\n            output.push({\"topic\": \"tradfri\", \"payload\": { \"tradfri_id\": msg.payload[i].devices[j].id, \"type\": msg.payload[i].devices[j].type, \"state\": \"off\"}});\n        }\n    }\n}\n\nreturn [output];","outputs":1,"noerr":0,"x":530,"y":1240,"wires":[["5e84cd4a.9ac124"]]},{"id":"482a07b.67d35f8","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"a","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":1240,"wires":[["546a42ba.a63fdc"]]},{"id":"43007f42.c9e28","type":"change","z":"eb97cc51.da1ca","name":"Bulb 1, Scene 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":255,\"color\":\"warm\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1540,"wires":[["7effe490.edce1c"]]},{"id":"8c48f800.13aeb8","type":"change","z":"eb97cc51.da1ca","name":"Bulb 1, Scene 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":60,\"color\":\"glow\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1580,"wires":[["f2c0545e.991138"]]},{"id":"e5f3d0d7.8084b","type":"function","z":"eb97cc51.da1ca","name":"Dim all lights","func":"var output = [];\n\n// loop through the groups\nfor (var i=0; i<msg.payload.length; i++) {\n    // loop through each bulb in the group\n    for (var j=0; j<msg.payload[i].devices.length; j++) {\n        if (msg.payload[i].devices[j].type.indexOf(\"bulb\")!==-1) {\n            if (msg.payload[i].devices[j].on) {\n                output.push({\"topic\": \"tradfri\", \"payload\": { \"tradfri_id\": msg.payload[i].devices[j].id, \"type\": msg.payload[i].devices[j].type, \"state\": \"on\", \"brightness\": 100}});\n            }\n        }\n    }\n}\nreturn [output];","outputs":1,"noerr":0,"x":530,"y":1440,"wires":[["7b485fac.26d9c"]]},{"id":"b9c146d1.c015e8","type":"change","z":"eb97cc51.da1ca","name":"Full brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":255,\"color\":\"normal\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1700,"wires":[["f8f1cead.a415c","382fe223.a58f7e"]]},{"id":"f8f1cead.a415c","type":"delay","z":"eb97cc51.da1ca","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":1740,"wires":[["8150ff13.9c65e"]]},{"id":"8150ff13.9c65e","type":"change","z":"eb97cc51.da1ca","name":"Half brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":128,\"color\":\"normal\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1780,"wires":[["c6d99aec.da9978","382fe223.a58f7e"]]},{"id":"f59af7c7.35d918","type":"change","z":"eb97cc51.da1ca","name":"Full brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":255,\"color\":\"normal\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1860,"wires":[["aefc7a3f.ee7e78","382fe223.a58f7e"]]},{"id":"64d9e1a9.02f15","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":1940,"wires":[["382fe223.a58f7e"]]},{"id":"c6d99aec.da9978","type":"delay","z":"eb97cc51.da1ca","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":1820,"wires":[["f59af7c7.35d918"]]},{"id":"aefc7a3f.ee7e78","type":"delay","z":"eb97cc51.da1ca","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":1900,"wires":[["64d9e1a9.02f15"]]},{"id":"c51c0739.1fd5e8","type":"bigtimer","z":"eb97cc51.da1ca","outtopic":"","outpayload1":"start","outpayload2":"off","name":"Big Timer","lat":"46.08","lon":"18.27","starttime":"360","endtime":"450","startoff":0,"endoff":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"x":420,"y":2080,"wires":[["4735e2eb.b98b4c"],[],[]]},{"id":"9071ac76.9a6ee","type":"comment","z":"eb97cc51.da1ca","name":"Simple on/off","info":"The two change nodes will convert any\nmessage to 'on' and 'off' commands.\nSo any signal coming from any device\ncan be used to set state of the lamp","x":130,"y":760,"wires":[]},{"id":"13acf6af.f374b9","type":"comment","z":"eb97cc51.da1ca","name":"Conversion of MQTT 0/1 to on/off","info":"MQTT on/off commands are usually '0' and '1'\nthis examples converts them to on/off\nwhich is expected my Tradfri","x":190,"y":960,"wires":[]},{"id":"3f76400.cf60fc","type":"comment","z":"eb97cc51.da1ca","name":"Setting brightness","info":"Payload is passed in JSON format with a brightness parameter.\nSetting the brightness makes the bulb to switch to\nthat brightness immediately, there is no fade.\nSetting the brightness on a bulb which is off\nturns it on automatically.","x":150,"y":1100,"wires":[]},{"id":"1ee75dee.08fad2","type":"comment","z":"eb97cc51.da1ca","name":"All lights off","info":"Cycle through all the Tradfri lights, and turn them off","x":130,"y":1200,"wires":[]},{"id":"d5b73d15.a4c4f","type":"function","z":"eb97cc51.da1ca","name":"All lights on","func":"var output = [];\n\n// loop through the groups\nfor (var i=0; i<msg.payload.length; i++) {\n    // loop through each bulb in the group\n    for (var j=0; j<msg.payload[i].devices.length; j++) {\n        if (msg.payload[i].devices[j].type.indexOf(\"bulb\")!==-1) {\n            output.push({\"topic\": \"tradfri\", \"payload\": { \"tradfri_id\": msg.payload[i].devices[j].id, \"type\": msg.payload[i].devices[j].type, \"state\": \"on\", \"brightness\": 255, \"color\": \"normal\"}});\n        }\n    }\n}\n\nreturn [output];","outputs":1,"noerr":0,"x":530,"y":1340,"wires":[["4e9c64f6.db7c0c"]]},{"id":"f40cb65c.e808f8","type":"comment","z":"eb97cc51.da1ca","name":"All lights on","info":"Cycle through all the Tradfri lights, \nand turn them on at full brightness","x":130,"y":1300,"wires":[]},{"id":"f5e9ea97.78cd68","type":"comment","z":"eb97cc51.da1ca","name":"Twilight mode","info":"Cycle through all the Tradfri lights, \nand what is on, reduce to 50% brightness","x":127.00000762939453,"y":1394.0000076293945,"wires":[]},{"id":"e51d6cbc.3d6dc","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"a","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":1340,"wires":[["7589b5ed.21ac5c"]]},{"id":"1f44739.1019c8c","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"a","payloadType":"str","repeat":"","crontab":"","once":false,"x":150,"y":1440,"wires":[["5d23d101.80a1"]]},{"id":"323ddda3.a9dc82","type":"comment","z":"eb97cc51.da1ca","name":"Scene mode","info":"Set multiple lights to a predefined setting","x":130,"y":1500,"wires":[]},{"id":"a5af055c.e4c168","type":"comment","z":"eb97cc51.da1ca","name":"Notification light","info":"Send a light pattern to a light to indicate\na particular action (e.g. email is received)","x":140,"y":1660,"wires":[]},{"id":"9bc1a19d.6bfc1","type":"comment","z":"eb97cc51.da1ca","name":"Wake up light","info":"Slowly increase the brightness of a bulb","x":150,"y":2000,"wires":[]},{"id":"4735e2eb.b98b4c","type":"function","z":"eb97cc51.da1ca","name":"Wake up light","func":"// Get the state value from last time\nvar state = context.get(\"state\");\nif (state===undefined) {\n    state = false;\n    context.set(\"state\",state);\n}\n// the counter counts upto full brightness \nvar counter = context.get(\"counter\");\nif (counter===undefined) {\n    counter = 0;\n    context.set(\"counter\",counter);\n}\nif (msg.topic===\"timecheck\") {\n    if (state) {\n        counter++;\n        //msg.payload.state=\"on\";\n        //msg.payload.color=\"warm\";\n        msg.payload = {\"brightness\" : Math.floor(counter/30*255)};\n        node.status({fill:\"blue\",shape:\"ring\",text:\"state: \"+state+\", counter: \"+counter});\n        context.set(\"counter\",counter);\n        return msg;\n    }\n} else {\n    if (msg.payload===\"start\") {\n        state = true;\n        counter = 0;\n        context.set(\"state\",state);\n        context.set(\"counter\",counter);\n        node.status({fill:\"blue\",shape:\"ring\",text:\"state: \"+state+\", counter: \"+counter});\n    }\n    if (msg.payload===\"off\") {\n        state = false;\n        counter = 0;\n        context.set(\"state\",state);\n        context.set(\"counter\",counter);\n        msg.payload=\"off\";\n        node.status({fill:\"blue\",shape:\"ring\",text:\"state: \"+state+\", counter: \"+counter});\n        return msg;\n    }\n}\n\n\n\n","outputs":1,"noerr":0,"x":680,"y":2080,"wires":[["184a01fa.8b540e"]]},{"id":"30bcb617.3608fa","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"timecheck","payload":"","payloadType":"str","repeat":"1","crontab":"","once":false,"x":450,"y":2160,"wires":[["4735e2eb.b98b4c"]]},{"id":"382fe223.a58f7e","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":735,"y":1700,"wires":[]},{"id":"184a01fa.8b540e","type":"link out","z":"eb97cc51.da1ca","name":"","links":["a04bcb92.feebc8"],"x":875,"y":2080,"wires":[]},{"id":"7effe490.edce1c","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":675,"y":1540,"wires":[]},{"id":"f2c0545e.991138","type":"link out","z":"eb97cc51.da1ca","name":"","links":["a04bcb92.feebc8"],"x":675,"y":1580,"wires":[]},{"id":"7b485fac.26d9c","type":"link out","z":"eb97cc51.da1ca","name":"","links":["3801269d.af94da"],"x":695,"y":1440,"wires":[]},{"id":"4e9c64f6.db7c0c","type":"link out","z":"eb97cc51.da1ca","name":"","links":["3801269d.af94da"],"x":695,"y":1340,"wires":[]},{"id":"5e84cd4a.9ac124","type":"link out","z":"eb97cc51.da1ca","name":"","links":["3801269d.af94da"],"x":695,"y":1240,"wires":[]},{"id":"107ebd2e.41eac3","type":"link out","z":"eb97cc51.da1ca","name":"","links":["a04bcb92.feebc8"],"x":695,"y":1140,"wires":[]},{"id":"b0928cb6.3f801","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":615,"y":820,"wires":[]},{"id":"8ef23ea5.1b0bc","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":615,"y":880,"wires":[]},{"id":"6b8d2c47.535184","type":"comment","z":"eb97cc51.da1ca","name":"Away time","info":"Turn off a light automatically at a set time","x":140,"y":2280,"wires":[]},{"id":"941ba239.e505f","type":"bigtimer","z":"eb97cc51.da1ca","outtopic":"","outpayload1":"off","outpayload2":"","name":"Big Timer","lat":"46.08","lon":"18.27","starttime":"480","endtime":"900","startoff":0,"endoff":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"x":440,"y":2380,"wires":[["8f879ad3.314eb8"],[],[]]},{"id":"8f879ad3.314eb8","type":"switch","z":"eb97cc51.da1ca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","outputs":1,"x":630,"y":2380,"wires":[["bc715480.cd4738"]]},{"id":"bc715480.cd4738","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":2380,"wires":[["45ec072a.063da8"]]},{"id":"45ec072a.063da8","type":"link out","z":"eb97cc51.da1ca","name":"","links":[],"x":955,"y":2380,"wires":[]},{"id":"3dfe3b79.054844","type":"comment","z":"eb97cc51.da1ca","name":"Garden lights","info":"Turn bulbs on at a set time and \nturn them off at a later time ","x":150,"y":2560,"wires":[]},{"id":"26a7ca64.f5af86","type":"bigtimer","z":"eb97cc51.da1ca","outtopic":"","outpayload1":"on","outpayload2":"off","name":"Big Timer","lat":"46.08","lon":"18.27","starttime":"5001","endtime":"1380","startoff":"-20","endoff":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":440,"y":2640,"wires":[["656470aa.49d45"],[],[]]},{"id":"656470aa.49d45","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c","a04bcb92.feebc8"],"x":835,"y":2620,"wires":[]},{"id":"ba32e605.386ab8","type":"comment","z":"eb97cc51.da1ca","name":"Burgler light","info":"Cycle bulb randomly","x":150,"y":2840,"wires":[]},{"id":"fe331940.cd6428","type":"bigtimer","z":"eb97cc51.da1ca","outtopic":"","outpayload1":"start","outpayload2":"end","name":"Big Timer","lat":"46.08","lon":"18.27","starttime":"5001","endtime":"1380","startoff":"60","endoff":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":417,"y":2940,"wires":[["d1a8a10d.55794","5d910e20.3cfd9","40a1d621.28b288","8de241a9.18721","80cf2331.bcfca"],[],[]]},{"id":"bb160106.eebbc","type":"delay","z":"eb97cc51.da1ca","name":"Random delay","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"15","randomLast":"20","randomUnits":"minutes","drop":false,"x":1020,"y":2960,"wires":[["40a1d621.28b288"]]},{"id":"d1a8a10d.55794","type":"switch","z":"eb97cc51.da1ca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"start","vt":"str"},{"t":"eq","v":"end","vt":"str"}],"checkall":"true","outputs":2,"x":630,"y":2880,"wires":[["5d42a17f.cb22e"],["fe0e3ab7.adf9e8"]]},{"id":"5d42a17f.cb22e","type":"change","z":"eb97cc51.da1ca","name":"Turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":2920,"wires":[["bb160106.eebbc","8e6f16da.93bdf8"]]},{"id":"9d45bf7a.2ea54","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":3020,"wires":[["8e6f16da.93bdf8","8de241a9.18721"]]},{"id":"8e6f16da.93bdf8","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":1295,"y":2920,"wires":[]},{"id":"8fbd2d41.8c3da","type":"link out","z":"eb97cc51.da1ca","name":"","links":["a04bcb92.feebc8"],"x":1275,"y":3060,"wires":[]},{"id":"75caadf9.d46884","type":"change","z":"eb97cc51.da1ca","name":"Turn on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":3060,"wires":[["8fbd2d41.8c3da","a08f6b56.b7d028"]]},{"id":"a08f6b56.b7d028","type":"delay","z":"eb97cc51.da1ca","name":"Random delay","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"15","randomLast":"20","randomUnits":"minutes","drop":false,"x":1020,"y":3100,"wires":[["80cf2331.bcfca"]]},{"id":"fb1f1c3f.1d76c","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":3160,"wires":[["8fbd2d41.8c3da","5d910e20.3cfd9"]]},{"id":"fe0e3ab7.adf9e8","type":"change","z":"eb97cc51.da1ca","name":"Turn off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":3220,"wires":[["8e6f16da.93bdf8","8fbd2d41.8c3da"]]},{"id":"984eca2f.5d93d8","type":"inject","z":"eb97cc51.da1ca","name":"Manual","topic":"","payload":"manual","payloadType":"str","repeat":"","crontab":"","once":false,"x":170,"y":2100,"wires":[["c51c0739.1fd5e8"]]},{"id":"ea4081e.441a68","type":"inject","z":"eb97cc51.da1ca","name":"Auto","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"x":170,"y":2060,"wires":[["c51c0739.1fd5e8"]]},{"id":"4e98dfd0.0a5b4","type":"inject","z":"eb97cc51.da1ca","name":"Test: On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":200,"y":2140,"wires":[["c51c0739.1fd5e8"]]},{"id":"5d910e20.3cfd9","type":"function","z":"eb97cc51.da1ca","name":"Stop cycle?","func":"var state = context.get(\"state\");\nif (state===undefined) {\n    state = false;\n}\nswitch (msg.payload) {\n    case \"start\":\n        state = true;\n        context.set(\"state\",state);\n        break;\n    case \"end\":\n        state = false;\n        context.set(\"state\",state);\n        break;\n    default:\n        if (state) {\n            return msg;\n        }\n}\n","outputs":1,"noerr":0,"x":850,"y":2920,"wires":[["5d42a17f.cb22e"]]},{"id":"40a1d621.28b288","type":"function","z":"eb97cc51.da1ca","name":"Stop cycle?","func":"var state = context.get(\"state\");\nif (state===undefined) {\n    state = false;\n}\nswitch (msg.payload) {\n    case \"start\":\n        state = true;\n        context.set(\"state\",state);\n        break;\n    case \"end\":\n        state = false;\n        context.set(\"state\",state);\n        break;\n    default:\n        if (state) {\n            return msg;\n        }\n}\n","outputs":1,"noerr":0,"x":870,"y":3020,"wires":[["9d45bf7a.2ea54"]]},{"id":"8de241a9.18721","type":"function","z":"eb97cc51.da1ca","name":"Stop cycle?","func":"var state = context.get(\"state\");\nif (state===undefined) {\n    state = false;\n}\nswitch (msg.payload) {\n    case \"start\":\n        state = true;\n        context.set(\"state\",state);\n        break;\n    case \"end\":\n        state = false;\n        context.set(\"state\",state);\n        break;\n    default:\n        if (state) {\n            return msg;\n        }\n}\n","outputs":1,"noerr":0,"x":870,"y":3060,"wires":[["75caadf9.d46884"]]},{"id":"80cf2331.bcfca","type":"function","z":"eb97cc51.da1ca","name":"Stop cycle?","func":"var state = context.get(\"state\");\nif (state===undefined) {\n    state = false;\n}\nswitch (msg.payload) {\n    case \"start\":\n        state = true;\n        context.set(\"state\",state);\n        break;\n    case \"end\":\n        state = false;\n        context.set(\"state\",state);\n        break;\n    default:\n        if (state) {\n            return msg;\n        }\n}\n","outputs":1,"noerr":0,"x":870,"y":3160,"wires":[["fb1f1c3f.1d76c"]]},{"id":"646d5d3e.2d15c4","type":"tradfri-out","z":"eb97cc51.da1ca","name":"TRADFRI bulb E27 WS opal 980lm","dtype":"device","tradfri_id":"65538","hub":"aeae6eaa.10db3","output":false,"x":640,"y":140,"wires":[]},{"id":"eeb35e14.1887f","type":"tradfri-get","z":"eb97cc51.da1ca","name":"","hub":"aeae6eaa.10db3","x":700,"y":260,"wires":[["c7f8f281.3b122"]]},{"id":"dcb1baa4.27cb98","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":110,"y":120,"wires":[["646d5d3e.2d15c4"]]},{"id":"25ea0a29.8ea506","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":110,"y":160,"wires":[["646d5d3e.2d15c4"]]},{"id":"191c9826.af7068","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"warm\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":240,"wires":[["646d5d3e.2d15c4"]]},{"id":"661aac18.70b7c4","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"normal\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":280,"wires":[["646d5d3e.2d15c4"]]},{"id":"a05ce754.c12428","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"cool\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":320,"wires":[["646d5d3e.2d15c4"]]},{"id":"5f3aa3.5701d55c","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 50}","payloadType":"json","repeat":"","crontab":"","once":false,"x":200,"y":400,"wires":[["646d5d3e.2d15c4"]]},{"id":"314a3423.82dfcc","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 255}","payloadType":"json","repeat":"","crontab":"","once":false,"x":210,"y":440,"wires":[["646d5d3e.2d15c4"]]},{"id":"f0b78b85.20ead8","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 100, \"color\": \"warm\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":270,"y":500,"wires":[["646d5d3e.2d15c4"]]},{"id":"c72c8816.42e0b8","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 255, \"color\": \"cool\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":270,"y":540,"wires":[["646d5d3e.2d15c4"]]},{"id":"5048064e.ef8d88","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"a","payloadType":"str","repeat":"","crontab":"","once":false,"x":550,"y":260,"wires":[["eeb35e14.1887f"]]},{"id":"c7f8f281.3b122","type":"debug","z":"eb97cc51.da1ca","name":"","active":true,"console":"false","complete":"false","x":870,"y":260,"wires":[]},{"id":"557ca3ee.f57b2c","type":"tradfri-out","z":"eb97cc51.da1ca","name":"TRADFRI bulb E27 opal 1000lm","dtype":"device","tradfri_id":"65537","hub":"aeae6eaa.10db3","output":false,"x":630,"y":80,"wires":[]},{"id":"33234483.17bd3c","type":"link in","z":"eb97cc51.da1ca","name":"Bulb 1 WS","links":["b0928cb6.3f801","8ef23ea5.1b0bc","d3d190e1.bb0d","7effe490.edce1c","382fe223.a58f7e","8e6f16da.93bdf8","656470aa.49d45"],"x":295,"y":100,"wires":[["646d5d3e.2d15c4"]]},{"id":"a04bcb92.feebc8","type":"link in","z":"eb97cc51.da1ca","name":"Bulb 2","links":["107ebd2e.41eac3","f2c0545e.991138","184a01fa.8b540e","8fbd2d41.8c3da","656470aa.49d45"],"x":395,"y":80,"wires":[["557ca3ee.f57b2c"]]},{"id":"37d8551b.e3a79a","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":820,"wires":[["9c85cee1.c74df"]]},{"id":"4d616ba5.6de444","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":880,"wires":[["3585b9c2.ca7166"]]},{"id":"462ec75c.2e52f8","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":1000,"wires":[["a0b961ee.1e86e"]]},{"id":"9525dc4b.fbf12","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":1040,"wires":[["a0b961ee.1e86e"]]},{"id":"d3d190e1.bb0d","type":"link out","z":"eb97cc51.da1ca","name":"","links":["33234483.17bd3c"],"x":835,"y":1000,"wires":[]},{"id":"8909bd72.012fa","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":1140,"wires":[["e7290df7.f6f36"]]},{"id":"4b83179e.8ac948","type":"tradfri-out","z":"eb97cc51.da1ca","name":"By msg.tradfri_id","dtype":"","tradfri_id":"0","hub":"aeae6eaa.10db3","output":false,"x":710,"y":400,"wires":[]},{"id":"3801269d.af94da","type":"link in","z":"eb97cc51.da1ca","name":"Tradfri by ID","links":["5e84cd4a.9ac124","4e9c64f6.db7c0c","7b485fac.26d9c"],"x":535,"y":400,"wires":[["4b83179e.8ac948"]]},{"id":"f00daa5.4734258","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":1560,"wires":[["43007f42.c9e28","8c48f800.13aeb8"]]},{"id":"c54f783d.210ef8","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":140,"y":1700,"wires":[["b9c146d1.c015e8"]]},{"id":"7589b5ed.21ac5c","type":"tradfri-get","z":"eb97cc51.da1ca","name":"","hub":"aeae6eaa.10db3","x":340,"y":1340,"wires":[["d5b73d15.a4c4f"]]},{"id":"546a42ba.a63fdc","type":"tradfri-get","z":"eb97cc51.da1ca","name":"","hub":"aeae6eaa.10db3","x":340,"y":1240,"wires":[["66ec280.ceab9d8"]]},{"id":"5d23d101.80a1","type":"tradfri-get","z":"eb97cc51.da1ca","name":"","hub":"aeae6eaa.10db3","x":340,"y":1440,"wires":[["e5f3d0d7.8084b"]]},{"id":"5f6810b.beebff","type":"inject","z":"eb97cc51.da1ca","name":"Test: Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":200,"y":2180,"wires":[["c51c0739.1fd5e8"]]},{"id":"900cc760.ea9c18","type":"inject","z":"eb97cc51.da1ca","name":"Manual","topic":"","payload":"manual","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2380,"wires":[["941ba239.e505f"]]},{"id":"a5828b72.fec988","type":"inject","z":"eb97cc51.da1ca","name":"Auto","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2340,"wires":[["941ba239.e505f"]]},{"id":"7aeff8be.ec6e08","type":"inject","z":"eb97cc51.da1ca","name":"Test: On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":2420,"wires":[["941ba239.e505f"]]},{"id":"9292c680.fbb2c8","type":"inject","z":"eb97cc51.da1ca","name":"Test: Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":2460,"wires":[["941ba239.e505f"]]},{"id":"9bf2449f.363228","type":"inject","z":"eb97cc51.da1ca","name":"Manual","topic":"","payload":"manual","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2660,"wires":[["26a7ca64.f5af86"]]},{"id":"23d7e713.1e7518","type":"inject","z":"eb97cc51.da1ca","name":"Auto","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2620,"wires":[["26a7ca64.f5af86"]]},{"id":"bf5b1e97.aee92","type":"inject","z":"eb97cc51.da1ca","name":"Test: On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":2700,"wires":[["26a7ca64.f5af86"]]},{"id":"4e388fa6.50572","type":"inject","z":"eb97cc51.da1ca","name":"Test: Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":2740,"wires":[["26a7ca64.f5af86"]]},{"id":"2077628e.a28c7e","type":"inject","z":"eb97cc51.da1ca","name":"Manual","topic":"","payload":"manual","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2940,"wires":[["fe331940.cd6428"]]},{"id":"73895e9b.6f74e","type":"inject","z":"eb97cc51.da1ca","name":"Auto","topic":"","payload":"auto","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":2900,"wires":[["fe331940.cd6428"]]},{"id":"5715616a.5ebd2","type":"inject","z":"eb97cc51.da1ca","name":"Test: On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":2980,"wires":[["fe331940.cd6428"]]},{"id":"14e32a09.e77f56","type":"inject","z":"eb97cc51.da1ca","name":"Test: Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":220,"y":3020,"wires":[["fe331940.cd6428"]]},{"id":"4527cea0.03de6","type":"tradfri-out","z":"eb97cc51.da1ca","name":"TRADFRI group (group)","dtype":"group","tradfri_id":"194147","hub":"aeae6eaa.10db3","output":false,"x":650,"y":3380,"wires":[]},{"id":"7b758e66.9fe78","type":"comment","z":"eb97cc51.da1ca","name":"Working with remotes","info":"","x":180,"y":3320,"wires":[]},{"id":"aeccce73.7d1e5","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":3380,"wires":[["4527cea0.03de6"]]},{"id":"7ef4fc1.b069704","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":3420,"wires":[["4527cea0.03de6"]]},{"id":"7db677dc.302198","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"warm\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":260,"y":3480,"wires":[["4527cea0.03de6"]]},{"id":"6103b4ea.52425c","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"normal\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":260,"y":3520,"wires":[["4527cea0.03de6"]]},{"id":"f9f1e2e.42ece2","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"color\": \"cool\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":260,"y":3560,"wires":[["4527cea0.03de6"]]},{"id":"45c31cdb.cb0fe4","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 50}","payloadType":"json","repeat":"","crontab":"","once":false,"x":300,"y":3640,"wires":[["4527cea0.03de6"]]},{"id":"631b1a2.7fe93e4","type":"inject","z":"eb97cc51.da1ca","name":"","topic":"","payload":"{\"brightness\": 255}","payloadType":"json","repeat":"","crontab":"","once":false,"x":310,"y":3680,"wires":[["4527cea0.03de6"]]},{"id":"aeae6eaa.10db3","type":"tradfri-config","z":"","name":"Gateway","hubip":"192.168.1.115","sid":"4MfG9dNXwVgfVbh3","coap":"/home/pi/.node-red/node_modules/node-tradfri-argon/lib/coap-client-raspbian"}]
nygma2004

Flow Info

created 3 weeks, 2 days ago

Node Types

Core
  • change (x17)
  • comment (x13)
  • debug (x1)
  • delay (x5)
  • function (x8)
  • inject (x44)
  • switch (x3)
Other

Tags

  • tradfri
  • ikea
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option