Thanks, what you describe is exactly what I do, but with a twist. The ecosystem I add the bulbs to has a dynamic configuration possibility which is driven by device detection (not specific for LIFX only), and configuration by a user through a GUI. However, the configuration of the ecosystem can also be provided by a Domain Specific Language, in which in the LIFX case, devices are identified by their MAC address.
So, I have one part of the code that does a general discovery of devices, using the V1 compatibility mode by binding the 56700 port, and reading back all the responses, and converting that in to what we call discovery results in a kind of inbox, from which the user can select and configure devices
For each bulb in the system, either added through the GUI, or as defined, there is a separate thread running doing all the management and communications. Since bulbs can be defined in a DSL, where there is no discovery as such, well, each thread (or handler, as we call them), needs to discover the bulbs on the LAN. (since we only have the bulb MAC address as configuration parameter). It has to be done by bulb separately, as each bulb (or device in general, in the ecosystem) can be put online, offline, …in the ecosystem . In essence, what I have at startup, is that each thread will broadcast using a specifically bound port (56701, 56702, and so forth), match the returned responses with the MAC address it is managing, configure the bulb, and continue all further communication using unicast. Exactly as you describe. (but I agree, if you have 3 bulbs, you get back 3 x 3 broadcast responses initially)
The problem lies in the fact that when these broadcasts are sent at the same time (well, almost, as it depends on other code execution and so forth, but it is pretty close at the same time), the bulbs seem to discard any broadcast message and only take into consideration the last source they see
I could imagine that the solution lies in pacing the broadcasts on the LAN, allowing the bulbs to respond. But how long should that interval be?