Ikea ON/OFF Switch - Deconz - Multiple Examples of use

HI,
Sharing my findings instructions covering using the IKEA On/OFF switch for
image

  • Deconz Integration
  • Use of the 6 possible actions of this button
  • Toggle off/Action
  • 2, 3, 4, 5 etc clicks to derive action
  • Colour Loop (can be used for brightness)

Don’t be scared of the following - I’ll go in step by step


Getting the switch to work

In Node Red - you need the node “node-red-contrib-deconz”

  • Top right icon in Node-red, then “Manage Palette”, then swich to “Install” search “contrib-deconz” and install
    image

We will use the node in (It will show as “deconz-input”

  • First you need to configure the server
  • Click on the pen beside server
  • Put the IP address of your deconz (for me it’s the home assistant IP)
  • Port: 40850
  • skip API key for now
  • Websocket port 8081
  • leave rest as is.
  • Go to your deconz “phoscon” in another browser window
  • Top left menu > gateway > Advanced > Authenticate App
  • Go back to Node-red and hit the “Get Settings”
  • It should auto-populate the “API Key”. Update - and deploy node
  • You can see if it works if there’s a green dot under the “deconz-input” node
  • Editing this node, you should now be able to select your switch
  • ** This was a nightmare for me. I got it to work with this solution
    This was (hopefully) the most complicated part…

The 6 Actions possible

[{"id":"2a731f63.cb77c","type":"inject","z":"cbd6d85d.24f998","name":"ON - Click - Single","props":[{"p":"payload.buttonevent","v":"1002","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":840,"wires":[["2562c3b8.d8088c"]]},{"id":"ae8eab08.f26fe8","type":"inject","z":"cbd6d85d.24f998","name":"ON - Click - Hold","props":[{"p":"payload.buttonevent","v":"1001","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":880,"wires":[["2562c3b8.d8088c"]]},{"id":"9c229162.c6901","type":"inject","z":"cbd6d85d.24f998","name":"ON - Release - (After Long Hold)","props":[{"p":"payload.buttonevent","v":"1003","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":920,"wires":[["2562c3b8.d8088c"]]},{"id":"26029b92.c88d84","type":"inject","z":"cbd6d85d.24f998","name":"OFF - Release - (After Long Hold)","props":[{"p":"payload.buttonevent","v":"2003","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":240,"y":1060,"wires":[["2562c3b8.d8088c"]]},{"id":"4fd7f4d3.0f1bfc","type":"inject","z":"cbd6d85d.24f998","name":"OFF - Click - Hold","props":[{"p":"payload.buttonevent","v":"2001","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":1020,"wires":[["2562c3b8.d8088c"]]},{"id":"52857a77.4dbe14","type":"inject","z":"cbd6d85d.24f998","name":"OFF - Click - Single","props":[{"p":"payload.buttonevent","v":"2002","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":980,"wires":[["2562c3b8.d8088c"]]},{"id":"41dd1ffd.bb468","type":"comment","z":"cbd6d85d.24f998","name":"Simulation ON/OFF switch","info":"","x":170,"y":800,"wires":[]},{"id":"2562c3b8.d8088c","type":"switch","z":"cbd6d85d.24f998","name":"Ikea on/off codes","property":"payload.buttonevent","propertyType":"msg","rules":[{"t":"eq","v":"1002","vt":"str"},{"t":"eq","v":"1001","vt":"str"},{"t":"eq","v":"1003","vt":"str"},{"t":"eq","v":"2002","vt":"str"},{"t":"eq","v":"2001","vt":"str"},{"t":"eq","v":"2003","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":550,"y":920,"wires":[["df03dedc.d46d5"],["48c096f9.6e9298"],["ce6e4538.d1f118"],["300f76e2.30c01a"],["77853e3d.dc4a4"],["f5113739.dcb2c8"]],"outputLabels":["Single ON","Long ON","Long ON Release","Single OFF","Long OFF","Long OFF Release"],"info":"1001 long click on\n1002 single click on \n1003 release after long click on\n2001 long click off\n2002 single click off\n2003 release after long click off"},{"id":"fe94bc24.ea75c","type":"comment","z":"cbd6d85d.24f998","name":"Detect and switch","info":"Based on Ikea ON/OFF switch","x":550,"y":840,"wires":[]},{"id":"539fdf31.6e99","type":"deconz-input","z":"cbd6d85d.24f998","name":"Bed Button","server":"84275c62.5cd71","device":"68:0a:e2:ff:fe:78:98:b0-01-1000","device_name":"Lloyd Bed Button : ZHASwitch","topic":"","state":"0","output":"always","outputAtStartup":false,"x":120,"y":760,"wires":[["2562c3b8.d8088c"],[]]},{"id":"84275c62.5cd71","type":"deconz-server","name":"deoconz","ip":"192.168.86.67","port":"40850","apikey":"80F80F1CD0","ws_port":"8081","secure":false,"polling":"15"}]

image
This is pretty much self explanatory. The deconz-input will send different codes depending on what is pushed.
Useless info: If you didn’t know, the symbol I/O on the button of Ikea is… binary! I = 1 = Open, and O = 0 = Off… This symbol is universal instead of “on/off” which is… in English…
So per each side where you click on the button you can:

  • Single Click
  • Hold the Click
  • Release after long Hold

Very simple example:

  • Single Click = Light Toggle
  • Hold the Click = keep colors of a lights slowly change until your favourite color comes, then release(next) to stop the change
  • Release after long hold: Stop the loop of colors to the one you like

You could stop here and simply use this switch to do automations to your liking. Below are extras that could augment those flows.


Logic to "augment a toggle"
Why? I want to click the same button to either:

  • A: Turn off several lights if any of those lights are on
  • B: Only turn on one specific light
  • (Think bedside lamp “on/off” but also “off” for any other lights in the room
    To do this, you “fake” a toggle… Check the sate of “that single lamp”, if on - turn everything off, and then if off, turn only the bed lamp.
[{"id":"432109c8.2fad28","type":"inject","z":"cbd6d85d.24f998","name":"Plug this to your Ikea switch","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":1300,"wires":[["aa4f818.d3a838"]]},{"id":"aa4f818.d3a838","type":"api-current-state","z":"cbd6d85d.24f998","name":"Light 1","server":"a0eea9da.0fe1d8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.light_sleeping_room_1","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":370,"y":1340,"wires":[["a4bfd1bc.4fb97"],["9f384fad.dbfd2"]]},{"id":"9f384fad.dbfd2","type":"api-current-state","z":"cbd6d85d.24f998","name":"light 2","server":"a0eea9da.0fe1d8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"slee","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":370,"y":1400,"wires":[["a4bfd1bc.4fb97"],["b4635c44.4adec"]]},{"id":"b4635c44.4adec","type":"api-current-state","z":"cbd6d85d.24f998","name":"light 3","server":"a0eea9da.0fe1d8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.light_sleeping_room_3","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":370,"y":1460,"wires":[["a4bfd1bc.4fb97"],["cd268dcd.2df0b"]]},{"id":"cd268dcd.2df0b","type":"api-current-state","z":"cbd6d85d.24f998","name":"Bed Lamp","server":"a0eea9da.0fe1d8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.stone_lamp","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":390,"y":1520,"wires":[["a4bfd1bc.4fb97"],["a4bfd1bc.4fb97"]]},{"id":"a4bfd1bc.4fb97","type":"switch","z":"cbd6d85d.24f998","name":"on somewhere?","property":"data.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":620,"y":1420,"wires":[["fbcdfdb6.819ce"],["ac9e378.2bd23c8"]]},{"id":"20f2e8dd.bccb38","type":"comment","z":"cbd6d85d.24f998","name":"This creates a \"sensor\"","info":"","x":140,"y":1340,"wires":[]},{"id":"fbcdfdb6.819ce","type":"api-call-service","z":"cbd6d85d.24f998","name":"All lights to OFF","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.light_sleeping_room_1, light.light_sleeping_room_2, , light.light_sleeping_room_3, , light.stone_lamp","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":830,"y":1380,"wires":[[]]},{"id":"ac9e378.2bd23c8","type":"api-call-service","z":"cbd6d85d.24f998","name":"Only Bed Light ON","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.stone_lamp","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":830,"y":1440,"wires":[[]]},{"id":"a0eea9da.0fe1d8","type":"server","name":"Home Assistant New","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]


More with your switch with multiple clicks

  • Single click = action 1
  • Double Click = action 2
  • Tripple Click = action 3
  • Any more than that = action 4
  • (You can make it ten clicks if you’re that kind of person - but remember, it’s “within a certain time”

And this can be applies both to the “on” button and to the “off” button of the Ikea Switch

[{"id":"3d629236.f811ee","type":"inject","z":"cbd6d85d.24f998","name":"Plug this to your Ikea switch","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":1640,"wires":[["93b8e5d2.9b3958"]]},{"id":"93b8e5d2.9b3958","type":"function","z":"cbd6d85d.24f998","name":"Start Counting","func":"const arr = Array.from(Array(msg.payload), _ => msg);\nreturn [arr];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":1640,"wires":[["d9d8a08e.b82c3"]]},{"id":"d9d8a08e.b82c3","type":"function","z":"cbd6d85d.24f998","name":"Until...","func":"const timeout = 2000;\nlet count = context.get(\"count\") || 0;\nif(count === 0) {\n    setTimeout(() => {\n        node.status({});\n        msg.count = context.get(\"count\") || 0;\n        context.set(\"count\", 0);\n        node.send(msg);\n    }, timeout);\n}\ncontext.set(\"count\", ++count);\nnode.status({text: count});","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":1680,"wires":[["943699bd.19bd28"]]},{"id":"943699bd.19bd28","type":"switch","z":"cbd6d85d.24f998","name":"1,2,3 or more clicks","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":630,"y":1660,"wires":[["e64fcf57.5d519"],["ef72c69c.c3cfa8"],["ebe408e8.bd5998"],["d427b705.049b18"]]},{"id":"e64fcf57.5d519","type":"api-call-service","z":"cbd6d85d.24f998","name":"Stone ON","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.stone_lamp","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":840,"y":1600,"wires":[[]]},{"id":"ef72c69c.c3cfa8","type":"api-call-service","z":"cbd6d85d.24f998","name":"sleepin ON (Dim)","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.sleeping_room","data":"{\"brightness_pct\":\"10\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":870,"y":1640,"wires":[[]]},{"id":"ebe408e8.bd5998","type":"api-call-service","z":"cbd6d85d.24f998","name":"sleepin ON (bright)","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.sleeping_room","data":"{\"brightness_pct\":\"100\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":870,"y":1680,"wires":[[]]},{"id":"d427b705.049b18","type":"api-call-service","z":"cbd6d85d.24f998","name":"More clicks - turn everything off","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.sleeping_room","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":910,"y":1720,"wires":[[]]},{"id":"a0eea9da.0fe1d8","type":"server","name":"Home Assistant New","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The only thing you need to edit in the function nodes is the one called “until” if you want to change the timer (number of clicks within… 2 seconds). The code has 2000 milliseconds (2sec) so change to your liking. Test how quick you click… That’s why “10 clicks” starts to be a bit crazy. If you make it too slow, you will need to wait until it triggers.


Color Loop when holding a button pressed
You hold a button, the color loops, when you release the button, the color stops at the last color.

[{"id":"9cfbb638.d62368","type":"switch","z":"cbd6d85d.24f998","name":"Ikea on/off codes","property":"payload.buttonevent","propertyType":"msg","rules":[{"t":"eq","v":"1002","vt":"str"},{"t":"eq","v":"1001","vt":"str"},{"t":"eq","v":"1003","vt":"str"},{"t":"eq","v":"2002","vt":"str"},{"t":"eq","v":"2001","vt":"str"},{"t":"eq","v":"2003","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":170,"y":1940,"wires":[[],["3e04f87d.8a79f8"],["2d43a3d2.4ea01c"],[],[],[]],"outputLabels":["Single ON","Long ON","Long ON Release","Single OFF","Long OFF","Long OFF Release"],"info":"1001 long click on\n1002 single click on \n1003 release after long click on\n2001 long click off\n2002 single click off\n2003 release after long click off"},{"id":"2d43a3d2.4ea01c","type":"change","z":"cbd6d85d.24f998","name":"Stop Color loop","rules":[{"t":"set","p":"stopcall","pt":"flow","to":"yes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1980,"wires":[["eabb43f4.0d68a"]]},{"id":"3e04f87d.8a79f8","type":"change","z":"cbd6d85d.24f998","name":"Color loop ON","rules":[{"t":"set","p":"stopcall","pt":"flow","to":"no","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1860,"wires":[["eabb43f4.0d68a"]]},{"id":"eabb43f4.0d68a","type":"function","z":"cbd6d85d.24f998","name":"set var","func":"flow.set(\"i\", 0);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":1900,"wires":[["2c906fa7.696c"]]},{"id":"1561ad84.a79722","type":"delay","z":"cbd6d85d.24f998","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":660,"y":1960,"wires":[["2c906fa7.696c"]]},{"id":"2c906fa7.696c","type":"function","z":"cbd6d85d.24f998","name":"change rgb","func":"var i = flow.get(\"i\");\nvar red   = Math.round(Math.sin(0.3*i + 0) * 127 + 128);\nvar green = Math.round(Math.sin(0.3*i + 2) * 127 + 128);\nvar blue  = Math.round(Math.sin(0.3*i + 4) * 127 + 128);\n\ni++;\nif (i>=32) {\n    i = 0;\n}\n\nflow.set(\"i\", i);\n\nmsg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.rgb_color = \"[\" + red + \", \" + green + \", \" + blue + \"]\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":670,"y":1900,"wires":[["1561ad84.a79722","cf350b79.40bea8"]]},{"id":"5f22a4ce.47d18c","type":"switch","z":"cbd6d85d.24f998","name":"","property":"stopcall","propertyType":"flow","rules":[{"t":"eq","v":"no","vt":"str"},{"t":"eq","v":"yes","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":1940,"wires":[["2c21cbb.5bfa034"],["90d86602.0e2aa8"]]},{"id":"cf350b79.40bea8","type":"template","z":"cbd6d85d.24f998","name":"admin","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{ \"data\": {\"entity_id\" : \"light.20334154d8bfc01379ff\", \"rgb_color\" : {{payload.data.rgb_color}} }}","output":"str","x":850,"y":1880,"wires":[["5f22a4ce.47d18c"]],"icon":"node-red-contrib-color-convert/color-convert.png"},{"id":"90d86602.0e2aa8","type":"change","z":"cbd6d85d.24f998","name":"stop call","rules":[{"t":"set","p":"stopcall","pt":"flow","to":"neutral","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":1980,"wires":[[]]},{"id":"2c21cbb.5bfa034","type":"api-call-service","z":"cbd6d85d.24f998","name":"Cycle","server":"a0eea9da.0fe1d8","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1070,"y":1900,"wires":[[]]},{"id":"813f0226.c9242","type":"comment","z":"cbd6d85d.24f998","name":"Hold to trigger color loop","info":"","x":150,"y":1860,"wires":[]},{"id":"a0eea9da.0fe1d8","type":"server","name":"Home Assistant New","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Ok, this one was coded with the help of another use (I am useless in coding…).

  • You need to use the “long hold button pressed” and “stop after long hold button pressed” switches for this one.
  • You need to edit your light entity id in the code as shown in the screenshot. Make sure you only replace between the quotes - replace “light.20334154d8bfc01379ff” by “light.yourownlight”
3 Likes

Hi, thanks for sharing this flow! Its working great for me with “multiple clicks” and “colorloop” but when it comes to adjusting the brightness I get lost. Do you mind sharing that specific flow as well? Thank you

Hi,
Brightness is something I found difficult - especially with Deconz and Ikea. For some reasons (could be me), sending both a brightness and a color in a single event doesn’t work. I have to send each one sequentrially and add a “wait” for 1 sec in between.
For your specific question - have a look here

I think this guys did an entire trail on using those buttons as dimmers. Thanks!

1 Like

This is how I solved it with the on/off in Node Red.

[{"id":"cd50a1a26ebbdba9","type":"ha-device","z":"a787a77.9c16458","name":"Hold down","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_long_press","subtype":"dim_down"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":1240,"wires":[["81423ebd234c4b9d"]]},{"id":"32b28db994678e72","type":"api-call-service","z":"a787a77.9c16458","name":"Köket off","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.kokslampa","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":1020,"wires":[[]]},{"id":"d2fcd6e1a6abc0ec","type":"api-call-service","z":"a787a77.9c16458","name":"Köket on","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.kokslampa","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":860,"wires":[[]]},{"id":"e3cccd4158d914d9","type":"api-call-service","z":"a787a77.9c16458","name":"Hallen on","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.hallen","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":800,"wires":[[]]},{"id":"07cea14578610314","type":"ha-device","z":"a787a77.9c16458","name":"Click down","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_short_press","subtype":"turn_off"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":1000,"wires":[["2b5b0d4fdf737633"]]},{"id":"b31db815b45e4574","type":"api-call-service","z":"a787a77.9c16458","name":"Hallen off","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.hallen","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":640,"y":960,"wires":[[]]},{"id":"3ebb7b1e28e1b0c4","type":"ha-device","z":"a787a77.9c16458","name":"Click up","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_short_press","subtype":"turn_on"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":840,"wires":[["14fe5df7b273b2be"]]},{"id":"7c6c3b834945bbd1","type":"api-call-service","z":"a787a77.9c16458","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.kokslampa","data":"{\t    \"color_temp\": msg.data.attributes.color_temp+5\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":1400,"wires":[["56aef9bbc63db595"]]},{"id":"04413f16f4097883","type":"api-current-state","z":"a787a77.9c16458","name":"","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.kokslampa","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":690,"y":1400,"wires":[["7c6c3b834945bbd1"]]},{"id":"357378a1e06fbc23","type":"ha-device","z":"a787a77.9c16458","name":"Hold up","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_long_press","subtype":"dim_up"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":1400,"wires":[["b595e505de63eafd"]]},{"id":"14fe5df7b273b2be","type":"join","z":"a787a77.9c16458","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"0.75","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":840,"wires":[["4b03e6dd16fe4c62"]]},{"id":"e34e4e76bcf78caa","type":"debug","z":"a787a77.9c16458","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":1300,"wires":[]},{"id":"4b03e6dd16fe4c62","type":"function","z":"a787a77.9c16458","name":"","func":"if (msg.payload.length == 1){\n    return [msg, null];\n}else{\n    return [null, msg];\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":840,"wires":[["e3cccd4158d914d9"],["d2fcd6e1a6abc0ec"]]},{"id":"2b5b0d4fdf737633","type":"join","z":"a787a77.9c16458","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":1000,"wires":[["c8e675dbc1ee8343"]]},{"id":"c8e675dbc1ee8343","type":"function","z":"a787a77.9c16458","name":"","func":"if (msg.payload.length == 1){\n    return [msg, null];\n}else{\n    return [null, msg];\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":1000,"wires":[["b31db815b45e4574"],["32b28db994678e72"]]},{"id":"dfd1e4aafc64495e","type":"api-call-service","z":"a787a77.9c16458","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.kokslampa","data":"{\t    \"color_temp\": msg.data.attributes.color_temp-5\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":1240,"wires":[["42ccfe1f89f9211a"]]},{"id":"3ec4b50588ff519c","type":"api-current-state","z":"a787a77.9c16458","name":"","server":"4bbca37b.1700ec","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.kokslampa","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":690,"y":1240,"wires":[["dfd1e4aafc64495e"]]},{"id":"42ccfe1f89f9211a","type":"delay","z":"a787a77.9c16458","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1130,"y":1240,"wires":[["3f6b726c41247c6f"]]},{"id":"81423ebd234c4b9d","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"hold_down","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":1240,"wires":[["3ec4b50588ff519c"]]},{"id":"3f6b726c41247c6f","type":"switch","z":"a787a77.9c16458","name":"","property":"hold_down","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":1160,"wires":[["3ec4b50588ff519c"]]},{"id":"56aef9bbc63db595","type":"delay","z":"a787a77.9c16458","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1130,"y":1400,"wires":[["45dad87fa3ac107e"]]},{"id":"45dad87fa3ac107e","type":"switch","z":"a787a77.9c16458","name":"","property":"hold_up","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":1320,"wires":[["04413f16f4097883"]]},{"id":"fef3fe8c30c13ff0","type":"ha-device","z":"a787a77.9c16458","name":"Hold down release","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_long_release","subtype":"dim_down"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":1180,"wires":[["a390899f6dcda103"]]},{"id":"42b3a487edc0b69d","type":"ha-device","z":"a787a77.9c16458","name":"Hold up release","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"770b0eca92df31064acad1ab9a76ec51","event":{"device_id":"770b0eca92df31064acad1ab9a76ec51","domain":"zha","platform":"device","type":"remote_button_long_release","subtype":"dim_up"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":1340,"wires":[["5bc0c5760fc9fab5"]]},{"id":"a390899f6dcda103","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"hold_down","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1180,"wires":[[]]},{"id":"5bc0c5760fc9fab5","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"hold_up","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1340,"wires":[[]]},{"id":"b595e505de63eafd","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"hold_up","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":1400,"wires":[["04413f16f4097883"]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Single click turns on/off the light in the hallway, double click in the kitchen.
Then if I hold the button it enters this loop that sets the color temperature (but could be changed to brightness obviously) while the button is held down.
The switch is what “kills” the loop, and the switch is switched by the “Hold xx release” node

1 Like

Thanks, I will check that link and see if I can use something

Looks interesting, will try and see if it works for me as well. Thx for sharing