How to dimmer multiple bulbs connected to a Philips hue dimmer

Hello,

I am trying to assign to a Philips hue dimmer the control of 3 bulbs. I’ve created a flow in node red and I have configured what will happen when 2 of the 4 buttons will be pressed (with short or long press).

Now I would like to configure the other two buttons which will dimmer the mentioned bulbs.

I have made a function node which will take in consideration all the cases and the output of this function is passed out to a call service node.

There are some things that are still not clear for me, because I am a new in node red.

In the written function how to pass correctly the commands into the data field of the call service node.

The other thing is how to memorize the value of a variable for later use. In this case, because I am trying to increase or decrease the brightness of the bulbs with a step of 25, it will have a value between 0 and 255. The next time I will press again the button for increasing or decreasing it has to know the previous value.

The other thing that I cannot understand is that if I made a debug of the output of the variable object of the light entity, the attribute brightness is not present if the device is turned off or if I do not made changes to the brightness.