MDNS Discovery and a network of Things

I am currently developing a binding for a smart home system. The system consists of devices that can be accessed via gateway, which uses mDNS service for LAN (HTTP + JSON) communication. I try to use MDNSDiscoveryParticipant for this purpose. However - as far as I understand - it supports discovering only a single Thing, not a network of Things (getThingUID() method returns ThingUID, and not e.g. List<ThingUID>). However, I can still use it for discovering the gateway as a Bridge, which seems fine. But - subsequently - I need to add the rest of devices as Things, and I still would like to use some Discovery service to do this. I cannot achieve this using MDNSDiscoveryParticipant (or can I?), so I suppose I have to implement my own Discovery service extending AbstractDiscoveryService.

But can I have two Discovery services in one binding (one for mDNS of the gateway, and the second for retrieving the list of the rest of devices from the gateway)? If not, do I have to implement mDNS handling in my own AbstractDiscoveryService, or is there a way of using MDNSDiscoveryService for the purpose of discovering the list of devices accessible behind the mDNS gateway? Or can I somehow use MDNSDiscoveryParticipant for the discovery of the whole network of devices instead of a single Thing?

Yes you can have 2 discovery services … just make that they are not competing in the sense that they discover the exact same thing

Note, my understanding is that MDNSDiscoveryParticipant will just trigger multiple times (for each device) instead of providing a list

1 Like

Oh, just like that? Did not know that. Thank you.

Although I don’t know how to pass gateway access data provided by MDNSDiscoveryService to other AbstractDiscoveryService, which needs to have access to the Bridge in order to list devices behind its network. But maybe I will figure it out.

But here I have only one device available directly via mDNS. The rest is not visible directly in LAN, so MDNSDiscoveryService does not have a chance to discover them.

You could check discovery implementation of other bindings like digitalSTROM.
Bridge is discovered via mDNS and then a second discovery queries the bridge for attached things.

3 Likes