Expert help needed! HA Light control in subflows with push-buttons

Hi All,
I’m quite new to this, but I’ve made a good flow that allows on/off and dimmer move up/dn when holding and releasing a momentary switch.
Up/Down-direction is controlled by light level, over a certain level it goes up, otherwise down.
I even have double+triple press to do low light level warm or cold.

But… I’d really like to put this in a subflow, so I don’t have to make 50 copies of the flow. Trouble is, I have to use a non-mqtt input block to get light status (the blue one below), in order to decide if I should dim up/dn or even turn on before dim up. Does anyone have a good idea how to do this? Or a better way to realize this solution?
(The blue block requires the specific name of the bulb, and I don’t know how to extract that from the message and put it there…)

Any ideas, suggestions and input appreciated, thanks!

Plowing ahead here, any input would be greatly appreciated!

Where would you extract the entity id from?

That’s what I’m missing.
I’d love to put all the automation in a subflow, and then just connect a whole bunch of buttons as inputs to the subflow, and a whole bunch of lamps as outputs to the subflow…
Trouble is, to make the flow work, I need the lamp state… And I can’t find a way to do that using a z2mqtt node, it requires a HA node with the specific name of the bulb. And then I’m back to 50 copies of the full flow.

I would move the two mqtt nodes to use HA nodes or use another mqtt node and flow context to save the state of the light from mqtt.

This would allow you to create a sub flow and either set the entity id and mqtt topic once for all the nodes.

Great, now I’m getting somewhere… Would that mean a flow like the one below:

And then a subflow (simplified), where I reference the flow variable like this:

Thanks for the replies so far, I’m learning!