Improving my Hue Tap Dial flows

Hi, I am looking for some advice from someone more seasoned on the most efficient way to build my flows for the Hue Tap Switch. I am using it to control lights in the living room, I have these lights as a group.

Currently I watch the mqtt topic, check the message for what function was used on the dial. Here is my flow so far:

[{"id":"b57e2c42e12071aa","type":"mqtt in","z":"50c121da10fa2dc6","name":"","topic":"zigbee2mqtt/HueTapSwitch/action","qos":"2","datatype":"utf8","broker":"dd99acb22ce2046a","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":1660,"wires":[["67ce4c767ef8201a"]]},{"id":"67ce4c767ef8201a","type":"switch","z":"50c121da10fa2dc6","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"dial_rotate_left_step","vt":"str"},{"t":"eq","v":"dial_rotate_left_slow","vt":"str"},{"t":"eq","v":"dial_rotate_left_fast","vt":"str"},{"t":"eq","v":"dial_rotate_right_step","vt":"str"},{"t":"eq","v":"dial_rotate_right_slow","vt":"str"},{"t":"eq","v":"dial_rotate_right_fast","vt":"str"},{"t":"eq","v":"button_1_press","vt":"str"},{"t":"eq","v":"button_2_press","vt":"str"},{"t":"eq","v":"button_3_press","vt":"str"},{"t":"eq","v":"button_4_press","vt":"str"},{"t":"eq","v":"button_1_hold","vt":"str"},{"t":"eq","v":"button_2_hold","vt":"str"},{"t":"eq","v":"button_3_hold","vt":"str"},{"t":"eq","v":"button_4_hold","vt":"str"}],"checkall":"true","repair":true,"outputs":14,"x":390,"y":1660,"wires":[["4dbc99a96664588d"],["4dbc99a96664588d"],["357bd4bb6cb01298"],["43f9b3a4b2aea318"],["43f9b3a4b2aea318"],["bb92704aeb7673d0"],[],[],[],["f26d7ca51f3914a0"],["4ba24613eee1e756"],["4ba24613eee1e756"],["4ba24613eee1e756"],["4ba24613eee1e756"]]},{"id":"fc6a6086e5d97fd2","type":"function","z":"50c121da10fa2dc6","name":"Set Msg Bright Down Slow","func":"function newBrightness(current_brightness) {\n const newBrightnessPct = (current_brightness / 255 - 0.02) * 100\n return Math.max(1, Math.min(100, Math.round(newBrightnessPct)))\n}\n \nconst newMsg = {\n payload: {\n \"data\": {\n \"entity_id\": msg.payload.entity_id,\n \"brightness_pct\": newBrightness(msg.payload.attributes.brightness)\n }\n }\n}\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":1520,"wires":[["c9a2be6387def3f2"]]},{"id":"c9a2be6387def3f2","type":"api-call-service","z":"50c121da10fa2dc6","name":"Call Srv Light","server":"ab03efa3.0e64d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":[],"data":"{}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":1580,"wires":[[]]},{"id":"4dbc99a96664588d","type":"ha-get-entities","z":"50c121da10fa2dc6","name":"Get Lights","server":"ab03efa3.0e64d","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"group.livingroom_lights","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":1520,"wires":[["fc6a6086e5d97fd2"]]},{"id":"43f9b3a4b2aea318","type":"ha-get-entities","z":"50c121da10fa2dc6","name":"Get Lights","server":"ab03efa3.0e64d","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"group.livingroom_lights","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":1600,"wires":[["d968e528b264752b"]]},{"id":"d968e528b264752b","type":"function","z":"50c121da10fa2dc6","name":"Set Msg Bright Up Slow","func":"function newBrightness(current_brightness) {\n const newBrightnessPct = (current_brightness / 255 + 0.02) * 100\n return Math.max(0, Math.min(100, Math.round(newBrightnessPct)))\n}\n \nconst newMsg = {\n payload: {\n \"data\": {\n \"entity_id\": msg.payload.entity_id,\n \"brightness_pct\": newBrightness(msg.payload.attributes.brightness)\n }\n }\n}\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":1600,"wires":[["c9a2be6387def3f2"]]},{"id":"357bd4bb6cb01298","type":"ha-get-entities","z":"50c121da10fa2dc6","name":"Get Lights","server":"ab03efa3.0e64d","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"group.livingroom_lights","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":1560,"wires":[["e3676a9bdc66cefb"]]},{"id":"e3676a9bdc66cefb","type":"function","z":"50c121da10fa2dc6","name":"Set Msg Bright Down Fast","func":"function newBrightness(current_brightness) {\n const newBrightnessPct = (current_brightness / 255 - 0.2) * 100\n return Math.max(1, Math.min(100, Math.round(newBrightnessPct)))\n}\n \nconst newMsg = {\n payload: {\n \"data\": {\n \"entity_id\": msg.payload.entity_id,\n \"brightness_pct\": newBrightness(msg.payload.attributes.brightness)\n }\n }\n}\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":1560,"wires":[["c9a2be6387def3f2"]]},{"id":"bb92704aeb7673d0","type":"ha-get-entities","z":"50c121da10fa2dc6","name":"Get Lights","server":"ab03efa3.0e64d","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"group.livingroom_lights","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":1640,"wires":[["a5f928c6dd471cc0"]]},{"id":"a5f928c6dd471cc0","type":"function","z":"50c121da10fa2dc6","name":"Set Msg Bright Up Fast","func":"function newBrightness(current_brightness) {\n const newBrightnessPct = (current_brightness / 255 + 0.2) * 100\n return Math.max(0, Math.min(100, Math.round(newBrightnessPct)))\n}\n \nconst newMsg = {\n payload: {\n \"data\": {\n \"entity_id\": msg.payload.entity_id,\n \"brightness_pct\": newBrightness(msg.payload.attributes.brightness)\n }\n }\n}\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":1640,"wires":[["c9a2be6387def3f2"]]},{"id":"f26d7ca51f3914a0","type":"api-call-service","z":"50c121da10fa2dc6","name":"Call Scene","server":"ab03efa3.0e64d","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.living_room_thewall"],"data":"{}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":1700,"wires":[[]]},{"id":"4ba24613eee1e756","type":"api-call-service","z":"50c121da10fa2dc6","name":"Turn Off Lights","server":"ab03efa3.0e64d","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":[],"data":"{}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":1840,"wires":[[]]},{"id":"dd99acb22ce2046a","type":"mqtt-broker","name":"MQTTBroker","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"ab03efa3.0e64d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

One thing I am struggling with, I would like to use the button_hold action to turn of the lights, but what I find with the switch is when I hold a button down, first a button_press message is received, followed by the button_hold message - this causes my press action to fire, then my hold action. In this case I’d like to ignore the press because a hold is seen. Is this possible? Thanks.Preformatted text

Use _press_release instead of _press as trigger for the “on” signal.

1 Like

Hey, thanks for taking the time to read and reply. I struggled to get an answer here. Whilst its been many months since I asked this question, I did actually never address it and the tap switch which I had only brought to mess around initially, gathered dust. The press_release solves my issue nicely thank you. I might start playing with this switch more again now to see if it can replace all my hue dimmer switch v1’s in each room and be as intuitive with their defined on and off physical buttons.

Quite how I missed the press_release messages I don’t know. They even repeat with fast presses too so I can continue to count them for adding functionality to double and triple presses. Nice.

Yeah I was looking into getting a Blueprint and found your post.

Started with two and now have 12 across my home all configured in Node-RED currently, but was looking to stop using Node-RED as I just use Node-RED for the buttons now as some automations are a lot easier to do in HA itself than in Node-RED.

Here’s my flow in Node-RED with directly addressing the lights in MQTT.


[{"id":"ebbc2d7b871497af","type":"mqtt in","z":"33c3026627168682","name":"","topic":"zigbee2mqtt/Eettafel Knop/action","qos":"2","datatype":"auto-detect","broker":"94d64f2fd88c31a1","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":500,"wires":[["ee22245da9249e38"]]},{"id":"6a8435352f4b6639","type":"api-call-service","z":"33c3026627168682","name":"Open","server":"c8abec08.f4fbc","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.tuin_open"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":710,"y":700,"wires":[[]]},{"id":"c980d5f098750964","type":"mqtt out","z":"33c3026627168682","name":"","topic":"zigbee2mqtt/Eettafel Lamp boven/set","qos":"2","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"94d64f2fd88c31a1","x":1030,"y":520,"wires":[]},{"id":"3b4066c330fd9be4","type":"change","z":"33c3026627168682","name":"down","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness_step\":-19,\"transition\":2}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":580,"wires":[["c980d5f098750964","ecd91b67d8d3a29f"]]},{"id":"b91af1b955d03cdb","type":"change","z":"33c3026627168682","name":"up","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"brightness_step\":19,\"transition\":2}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":540,"wires":[["c980d5f098750964","ecd91b67d8d3a29f"]]},{"id":"ee22245da9249e38","type":"switch","z":"33c3026627168682","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button_1_press_release","vt":"str"},{"t":"eq","v":"button_1_hold","vt":"str"},{"t":"eq","v":"dial_rotate_right_step","vt":"str"},{"t":"eq","v":"dial_rotate_right_slow","vt":"str"},{"t":"eq","v":"dial_rotate_right_fast","vt":"str"},{"t":"eq","v":"dial_rotate_left_step","vt":"str"},{"t":"eq","v":"dial_rotate_left_slow","vt":"str"},{"t":"eq","v":"dial_rotate_left_fast","vt":"str"},{"t":"eq","v":"button_3_press_release","vt":"str"},{"t":"eq","v":"button_3_hold","vt":"str"},{"t":"eq","v":"button_2_press_release","vt":"str"},{"t":"eq","v":"button_4_press_release","vt":"str"},{"t":"eq","v":"button_2_hold","vt":"str"},{"t":"eq","v":"button_4_hold","vt":"str"}],"checkall":"true","repair":true,"outputs":14,"x":490,"y":620,"wires":[["30cf90921a5755fd"],["850b0ff2ad053e18"],["b91af1b955d03cdb"],["b91af1b955d03cdb"],["b91af1b955d03cdb"],["3b4066c330fd9be4"],["3b4066c330fd9be4"],["3b4066c330fd9be4"],["5823caac84bd1bfa"],["ee1f3f93d1859db2"],["6a8435352f4b6639"],["1f8f3511d4f2e24d"],["804103fcdcaa6f9a"],["804103fcdcaa6f9a"]]},{"id":"804103fcdcaa6f9a","type":"api-call-service","z":"33c3026627168682","name":"Dicht","server":"c8abec08.f4fbc","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.tuin_dicht"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":710,"y":780,"wires":[[]]},{"id":"1f8f3511d4f2e24d","type":"api-call-service","z":"33c3026627168682","name":"Zon","server":"c8abec08.f4fbc","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.tuin_zon"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":710,"y":740,"wires":[[]]},{"id":"ecd91b67d8d3a29f","type":"mqtt out","z":"33c3026627168682","name":"","topic":"zigbee2mqtt/Eettafel Lamp onder/set","qos":"2","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"94d64f2fd88c31a1","x":1030,"y":600,"wires":[]},{"id":"ee1f3f93d1859db2","type":"change","z":"33c3026627168682","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"state\":\"off\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":660,"wires":[["ecd91b67d8d3a29f"]]},{"id":"850b0ff2ad053e18","type":"change","z":"33c3026627168682","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"state\":\"off\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":500,"wires":[["c980d5f098750964"]]},{"id":"30cf90921a5755fd","type":"change","z":"33c3026627168682","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"state\":\"on\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":460,"wires":[["c980d5f098750964"]]},{"id":"5823caac84bd1bfa","type":"change","z":"33c3026627168682","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"state\":\"on\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":620,"wires":[["ecd91b67d8d3a29f"]]},{"id":"94d64f2fd88c31a1","type":"mqtt-broker","name":"MQTT","broker":"localhost","port":"1883","tls":"","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"c8abec08.f4fbc","type":"server","name":"Home Assistant","addon":true}]