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