MQTT is driving me crazy with inconsistent doings

It's my pleasure, always nice with a challenge for your mind!!!

The key essence here, at least my philosophy, break things down and separate what can/should be done as a service and presentation respectively. It will make it easier to understand, debug and maintain. It is also required if you want to serve multiple clients

The beauty contest to follow is to make a generic backend and frontend that will handle all your existing and future bulbs. Like bulb-x or something. So you might then have to think about the MQTT structure the bulbs are publishing to. Now you have "BULB-1/#". I do not know if it will be ok for the backend to subscribe to "#", it might be we would receive a lot of other "rubbish" as well. So it might be better if bulbs would publish like "MyBulbs/BULB-1/#" and the backend subscribes to "MyBulbs/#" if you wanna go generic. Obviously all publishing to MQTT would need a similar re-thinking

However, nothing prevents making x copies of the backed flow, one for each bulb and the same for each frontend flow. It will be efficient & good enough I think, it's not just as elegant and it involves more copy & pasting and it will be boring if you need to change anything else in the flows, you will have to edit all of them