Hue/Trådfri deCONZ dimmer (subflow)

Subflow to be used with node-red-contrib-deconz

Subflow Trådfri deconz dimmer

Example flow (the subflow needs two inputs and one output as shown) Single button deCONZ

The deCONZ TRÅDFRI on/off switch input node should be configured as follows: Single button deCONZ

The deCONZ light input node should be configured as follows (this is the default): Single button deCONZ

The deCONZ light output node should be configured as follows (same light entity as input): Single button deCONZ

The subflow is preconfigured for use with the IKEA Trådfri on/off (dimmer) switch. If you are using a Hue dimmer switch instead, the subflow should be configured as follows: Single button deCONZ

For best performance, use the same brand of bulbs in the same room.


Copy the subflow below to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option

[{"id":"384850fa.534dc","type":"subflow","name":"Hue/TRÅDFRI deCONZ dimmer","info":"","category":"","in":[{"x":90,"y":140,"wires":[{"id":"4c575ae3.fcb5e4"}]}],"out":[{"x":880,"y":180,"wires":[{"id":"fdd31551.94abb8","port":0},{"id":"70340ea1.f6e8f","port":0},{"id":"c3f9e831.664d28","port":0},{"id":"26e1c3e3.493d8c","port":0},{"id":"64598704.d68ab8","port":0},{"id":"cc20f5d4.ec2078","port":0}]}],"env":[{"name":"On","type":"str","value":"1002"},{"name":"Off","type":"str","value":"2002"},{"name":"Increase","type":"str","value":"1001"},{"name":"StopIncreasing","type":"str","value":"1003"},{"name":"Decrease","type":"str","value":"2001"},{"name":"StopDecreasing","type":"str","value":"2003"},{"name":"TransitionTime","type":"num","value":"30","ui":{"label":{"en-US":"Transition time (10-100)"},"type":"input","opts":{"types":["num"]}}},{"name":"On state","type":"str","value":"Resume","ui":{"type":"select","opts":{"opts":[{"l":{"en-US":"Resume"},"v":"Resume"},{"l":{"en-US":"Full brightness"},"v":"Full brightness"}]}}}],"color":"#E6E0F8","icon":"node-red/light.svg","status":{"x":880,"y":370,"wires":[{"id":"ceeb50b5.1b93f","port":0}]}},{"id":"88efce3b.9b11","type":"comment","z":"384850fa.534dc","name":"instructions + link to latest version of this subflow","info":"Latest version of this subflow can be found at\nhttps://flows.nodered.org/flow/1949af43de3db8133b039dac706372bd\n\nto the input add:\n1) button sending different pressed/released commands\n2) deCONZ in node with the light you want to dim and choose \"complete state payload\" + send state on start\n\nto the output add:\n1) \"deCONZ out\" node with the light you want to dim and choose command \"object json\". Leave transition time empty.","x":340,"y":40,"wires":[]},{"id":"b51c0caa.bc903","type":"change","z":"384850fa.534dc","name":"save snapshot","rules":[{"t":"set","p":"LightTurnedOn","pt":"flow","to":"payload.on","tot":"msg"},{"t":"set","p":"oldBrightness","pt":"flow","to":"payload.bri","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":370,"wires":[["ceeb50b5.1b93f"]]},{"id":"4c575ae3.fcb5e4","type":"switch","z":"384850fa.534dc","name":"Input filter","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"env"},{"t":"eq","v":"Off","vt":"env"},{"t":"eq","v":"Decrease","vt":"env"},{"t":"eq","v":"StopDecreasing","vt":"env"},{"t":"eq","v":"StopIncreasing","vt":"env"},{"t":"eq","v":"Increase","vt":"env"},{"t":"else"}],"checkall":"true","repair":false,"outputs":7,"x":130,"y":230,"wires":[["6fb3dc3c.0b7494"],["fdd31551.94abb8"],["26e1c3e3.493d8c"],["f74a70bc.42f5e"],["f74a70bc.42f5e"],["d99f3b08.8335b8"],["6a9b3f24.05d0b"]]},{"id":"fdd31551.94abb8","type":"change","z":"384850fa.534dc","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":false}","tot":"json"},{"t":"set","p":"oldPowerstate","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":160,"wires":[[]]},{"id":"70340ea1.f6e8f","type":"change","z":"384850fa.534dc","name":"Resume","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":true}","tot":"json"},{"t":"set","p":"LightTurnedOn","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":140,"wires":[[]]},{"id":"6a9b3f24.05d0b","type":"switch","z":"384850fa.534dc","name":"check payload","property":"payload.bri","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":370,"wires":[["b51c0caa.bc903"]]},{"id":"c3f9e831.664d28","type":"change","z":"384850fa.534dc","name":"Full brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":true, \"bri\":255}","tot":"json"},{"t":"set","p":"LightTurnedOn","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":100,"wires":[[]]},{"id":"6fb3dc3c.0b7494","type":"switch","z":"384850fa.534dc","name":"Resume or full brightness?","property":"On state","propertyType":"env","rules":[{"t":"eq","v":"Full brightness","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":400,"y":120,"wires":[["c3f9e831.664d28"],["70340ea1.f6e8f"]]},{"id":"64598704.d68ab8","type":"function","z":"384850fa.534dc","name":"start increasing brightness","func":"if (flow.get(\"allow\") !== false)\n{\nflow.set(\"allow\", false);\nvar oldBrightness = flow.get(\"oldBrightness\")||1;\nvar TransitionTime = env.get(\"TransitionTime\")||40;\nvar CalculatedTime = Math.round((TransitionTime/255*(255-oldBrightness)))\nif (CalculatedTime < 10) {CalculatedTime = 10;}\nmsg.payload = { on:true, bri: 255, transitiontime: CalculatedTime}\nreturn msg;\n}","outputs":1,"noerr":0,"x":700,"y":280,"wires":[[]]},{"id":"26e1c3e3.493d8c","type":"function","z":"384850fa.534dc","name":"start decreasing brightness","func":"if (flow.get(\"allow\") !== false)\n{\nflow.set(\"allow\", false);\nvar oldBrightness = flow.get(\"oldBrightness\")||1;\nvar TransitionTime = env.get(\"TransitionTime\")||40;\nvar CalculatedTime = Math.round((TransitionTime/255*oldBrightness))\nif (CalculatedTime < 10) {CalculatedTime = 10;}\nmsg.payload = { on:true, bri: 0, transitiontime: CalculatedTime}\nreturn msg;\n}","outputs":1,"noerr":0,"x":400,"y":200,"wires":[[]]},{"id":"f74a70bc.42f5e","type":"template","z":"384850fa.534dc","name":"Stop increasing/decreasing brightness","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"bri_inc\":0}","output":"json","x":430,"y":240,"wires":[["cc20f5d4.ec2078"]]},{"id":"66caff59.dfe67","type":"change","z":"384850fa.534dc","name":"Start from brightness = 0","rules":[{"t":"set","p":"oldBrightness","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":330,"wires":[["64598704.d68ab8"]]},{"id":"d99f3b08.8335b8","type":"switch","z":"384850fa.534dc","name":"LightTurnedOn?","property":"LightTurnedOn","propertyType":"flow","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":280,"wires":[["64598704.d68ab8"],["66caff59.dfe67"]]},{"id":"ceeb50b5.1b93f","type":"function","z":"384850fa.534dc","name":"share status","func":"msg.payload = { on:flow.get(\"LightTurnedOn\"), bri: flow.get(\"oldBrightness\")}\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":370,"wires":[[]]},{"id":"cc20f5d4.ec2078","type":"change","z":"384850fa.534dc","name":"allow increase/decrease","rules":[{"t":"set","p":"allow","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":240,"wires":[[]]}]

Flow Info

Created 4 years, 5 months ago
Updated 3 years, 10 months ago
Rating: 5 2

Owner

Actions

Rate:

Node Types

Core
  • change (x6)
  • comment (x1)
  • function (x3)
  • switch (x4)
  • template (x1)
Other
  • subflow (x1)

Tags

  • deCONZ
  • TRÅDFRI
  • TRADFRI
  • dimmer
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option