Light control via switch

Hello dear Node-Red Community,
I would like to dim some LED strips using a philips hue button. The whole thing is connected via zigbee2mqtt.
about the button:
short button press = ON or OFF
long button press = STEP UP or STEP DOWN

I have already created a flow in node red.
the dimming also works, but the long keystroke always outputs the command ON, so that the switching on and off does not work properly.
It would be nice if with short keystroke OFF = off / ON = last dimming level.
Perhaps the button is also unsuitable for this.
Has anyone implemented this differently and could help me here?

Thx

What sort of button are you talking about? A physical button? A dashboard button?

The standard dashboard button only triggers an action on (I think) release, not an action on press and another on release. If you search the forum you will probably find examples of how to do what you want. Maybe search for long button press for example.

Hello,
thank you for your answer.
It is a physical button.
Whether you press long or short, the device always sends the status ON.

How is the button connected?
What messages do you get from the button?

with a short key press:

1.3.2023, 16:32:08node: debug1 Bett
zigbee2mqtt/Hue Button Bett : msg.payload : Object
object
action: "press"
battery: 100
linkquality: 208
update: object
update_available: false
11.3.2023, 16:32:08node: debug1 Bett
zigbee2mqtt/Hue Button Bett : msg.payload : Object
object
action: "release"
battery: 100
linkquality: 208
update: object
update_available: false
11.3.2023, 16:32:08node: debug1 Bett
zigbee2mqtt/Hue Button Bett : msg.payload : Object
object
action: "on"
battery: 100
linkquality: 196
update: object
update_available: false

with a long key press:

13.3.2023, 18:54:55node: debug1 Bett
zigbee2mqtt/Hue Button Bett : msg.payload : Object
object
action: "hold"
battery: 100
linkquality: 104
update: object
update_available: false
13.3.2023, 18:54:55node: debug1 Bett
zigbee2mqtt/Hue Button Bett : msg.payload : Object
object
action: "brightness_step_up"
action_step_size: 56
action_transition_time: 0.09
battery: 100
linkquality: 104
update: object
update_available: false

I think I got it right.
Now I have only one problem. I would still like to switch the light on and off via a switch in the dashboard.
If the slider value is for example greater than 0 then the switch should jump to ON.
If I have the light on for example 80% and set the switch to OFF, the light should turn off. When I switch the switch back to ON the value should still be at 80.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.