IKEA Tradfri Dimmer in NodeRED

I'm recreating the original functionality of the IKEA TRADFRI Wireless Dimmer in NodeRed so you could use the button with any NodeRED enabled devices, not just IKEA ones! enter image description here

Instructions: You can read all set up instructions here


Features:

  • ON|OFF toggle
  • Brightness UP|DOWN
  • Custom increment step

Settings

  • Step increment brightness by X

More about me:

If you want to get the latest updates to this project you can follow me via your preferred social media:

And if you feeling like buying me a coffee or supporting me in a more continuous way:

I hope you have enjoyed the project!

[{"id":"67f9a36c.f4a1fc","type":"subflow","name":"Dimmer Settings","info":"","category":"","in":[{"x":400,"y":80,"wires":[{"id":"67fe2056.d8cd7"}]}],"out":[{"x":620,"y":80,"wires":[{"id":"67fe2056.d8cd7","port":0}]}],"env":[{"name":"Step","type":"num","value":"30"}],"color":"#3FADB5","icon":"node-red/cog.svg"},{"id":"67fe2056.d8cd7","type":"function","z":"67f9a36c.f4a1fc","name":"Step","func":"var x = env.get(\"Step\"); \nflow.set(\"$parent.Step\", x);\n\nmsg.payload = \"Your brightness increment has been set to: \" + x;\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":80,"wires":[[]]},{"id":"b940d21c.1fff3","type":"tab","label":"IKEA Dimmer in NodeRED","disabled":false,"info":"I'm recreating the original functionality of the IKEA TRADFRI Wireless Dimmer in NodeRed so you could use the button with any NodeRED enabled devices, not just IKEA ones!\n![enter image description here](https://notenoughtech.com/wp-content/uploads/2019/11/YouTube-Thumb-4.jpg)\n\n**Instructions:**\nYou can read all [set up instructions here](https://notenoughtech.com/featured/ikea-tradfri-wireless-dimmer-in-nodered/)\n\n---\n\n**Features**:\n\n-   ON|OFF toggle\n-   Brightness UP|DOWN\n-   Custom increment step\n\n---\n# Settings\n - **Step** increment brightness by X "},{"id":"c786b38d.959c2","type":"switch","z":"b940d21c.1fff3","name":"Messages","property":"payload.click","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"brightness_stop","vt":"str"},{"t":"eq","v":"brightness_up","vt":"str"},{"t":"eq","v":"brightness_down","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":310,"y":320,"wires":[["e6af827.9be108"],["d39b4454.a0cc78"],["d9fd37b3.5511c8"],["dc0cf8a0.604028","359b8cf5.78b704"],["cebc76c0.d58538","359b8cf5.78b704"]]},{"id":"dc0cf8a0.604028","type":"function","z":"b940d21c.1fff3","name":"Brightness up","func":"var step = flow.get(\"Step\");\nvar brightness =  flow.get(\"IKEA_bulb1_brightness\");\n\nif(brightness > 0){\n    brightness = brightness + step;\n    flow.set(\"IKEA_bulb1_brightness\", brightness);\n\t}\n\t\nif(brightness >= 255){\n    brightness = 254;\n    flow.set('press', false);\n    flow.set(\"IKEA_bulb1_brightness\", brightness);\n    }\n\nmsg.payload = {\"state\":\"ON\",\n               \"brightness\":brightness};\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":560,"wires":[["aab4e92d.c91e28","51644345.67539c"]]},{"id":"cebc76c0.d58538","type":"function","z":"b940d21c.1fff3","name":"Brightness down","func":"var step = flow.get(\"Step\");\nvar brightness =  flow.get(\"IKEA_bulb1_brightness\");\n\nif(brightness <= 255){\n    brightness = brightness - step; \n    flow.set(\"IKEA_bulb1_brightness\", brightness);\n\t}\n\t\nif(brightness <= 0){\n    brightness = 1;\n    flow.set('press', false);\n    flow.set(\"IKEA_bulb1_brightness\", brightness);\n    }\n\nmsg.payload = {\"state\":\"ON\",\n               \"brightness\":brightness};\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":600,"wires":[["aab4e92d.c91e28","bf17a32.3347d6"]]},{"id":"b132cd47.5361c","type":"switch","z":"b940d21c.1fff3","name":"Control loop","property":"press","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":740,"wires":[["cebc76c0.d58538"]]},{"id":"420aac7b.c64574","type":"switch","z":"b940d21c.1fff3","name":"Control loop","property":"press","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":780,"wires":[["dc0cf8a0.604028"]]},{"id":"51644345.67539c","type":"delay","z":"b940d21c.1fff3","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":780,"wires":[["420aac7b.c64574"]]},{"id":"bf17a32.3347d6","type":"delay","z":"b940d21c.1fff3","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":740,"wires":[["b132cd47.5361c"]]},{"id":"b94acd19.7caef","type":"comment","z":"b940d21c.1fff3","name":"loop every 500 ms","info":"","x":570,"y":700,"wires":[]},{"id":"7f69520d.788e3c","type":"comment","z":"b940d21c.1fff3","name":"increase/decrease brightness","info":"","x":500,"y":520,"wires":[]},{"id":"359b8cf5.78b704","type":"change","z":"b940d21c.1fff3","name":"start","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":360,"wires":[["30695df.bdaa9a2"]]},{"id":"d9fd37b3.5511c8","type":"change","z":"b940d21c.1fff3","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":400,"wires":[["30695df.bdaa9a2"]]},{"id":"30695df.bdaa9a2","type":"change","z":"b940d21c.1fff3","name":"Control the loop","rules":[{"t":"set","p":"press","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":375,"wires":[[]]},{"id":"99938687.36ff98","type":"comment","z":"b940d21c.1fff3","name":"start/stop loop","info":"","x":690,"y":345,"wires":[]},{"id":"da10d307.eded8","type":"mqtt in","z":"b940d21c.1fff3","name":"IKEA Light","topic":"zigbee2mqtt/ikeabulbc1","qos":"2","datatype":"json","broker":"eca6af44.5297b","x":120,"y":180,"wires":[["8a13f8be.ca9058"]]},{"id":"aab4e92d.c91e28","type":"mqtt out","z":"b940d21c.1fff3","name":"IKEA Light Control","topic":"zigbee2mqtt/ikeabulbc1/set","qos":"","retain":"","broker":"eca6af44.5297b","x":950,"y":260,"wires":[]},{"id":"4ac241f7.278ac","type":"debug","z":"b940d21c.1fff3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":180,"wires":[]},{"id":"394c130c.943f4c","type":"mqtt out","z":"b940d21c.1fff3","name":"IKEA Light Status","topic":"zigbee2mqtt/ikeabulbc1/get","qos":"","retain":"","broker":"eca6af44.5297b","x":450,"y":120,"wires":[]},{"id":"e79a3c52.ae408","type":"inject","z":"b940d21c.1fff3","name":"","topic":"","payload":"{\"state\":\"\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":120,"wires":[["394c130c.943f4c"]]},{"id":"e6af827.9be108","type":"function","z":"b940d21c.1fff3","name":"ON","func":"msg.payload = { \"state\":\"ON\"};\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":260,"wires":[["aab4e92d.c91e28"]]},{"id":"d39b4454.a0cc78","type":"function","z":"b940d21c.1fff3","name":"OFF","func":"msg.payload = { \"state\":\"OFF\"};\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":300,"wires":[["aab4e92d.c91e28"]]},{"id":"8a13f8be.ca9058","type":"delay","z":"b940d21c.1fff3","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":390,"y":180,"wires":[["523a3a9a.7d63f4"]]},{"id":"523a3a9a.7d63f4","type":"function","z":"b940d21c.1fff3","name":"Update","func":"\nflow.set(\"IKEA_bulb1_brightness\", msg.payload.brightness);\n\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":180,"wires":[["4ac241f7.278ac"]]},{"id":"79841cb4.d328e4","type":"inject","z":"b940d21c.1fff3","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":60,"wires":[["c5ad66b8.e13328"]]},{"id":"c5ad66b8.e13328","type":"subflow:67f9a36c.f4a1fc","z":"b940d21c.1fff3","name":"","env":[],"x":320,"y":60,"wires":[["865a0e53.ef584"]]},{"id":"865a0e53.ef584","type":"debug","z":"b940d21c.1fff3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":60,"wires":[]},{"id":"c10f24b5.2fcc78","type":"mqtt in","z":"b940d21c.1fff3","name":"IKEA Button","topic":"zigbee2mqtt/ikeadimmerbronze","qos":"1","datatype":"json","broker":"eca6af44.5297b","x":90,"y":320,"wires":[["c786b38d.959c2"]]},{"id":"eca6af44.5297b","type":"mqtt-broker","z":"","name":"MQTT","broker":"dockerpi.local","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Flow Info

Created 4 years, 9 months ago
Updated 4 years, 7 months ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • change (x3)
  • comment (x3)
  • debug (x2)
  • delay (x3)
  • function (x6)
  • inject (x2)
  • mqtt in (x2)
  • mqtt out (x2)
  • mqtt-broker (x1)
  • switch (x3)
Other
  • subflow (x1)
  • subflow:67f9a36c.f4a1fc (x1)
  • tab (x1)

Tags

  • IKEA
  • Tradfri
  • Dimmer
  • Button
  • Toggle
  • Zigbee
  • lights
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option