[2.4.1.151] mDNS listener how-to - apps only

To use the feature, the app needs to tell the hub to listen to a particular service. Once app registers the listener, it will collect service information in the background for as long as the hub is up.

Since it takes time to collect mDNS data, the best place to register the listener is on system startup, as shown in example below. Then call getMDNSEntries() function, and it will return a list of Maps with all available MDNS information stored as key/value pairs.

void updated() {
    subscribe(location, "systemStart", "bootHandler")
}

void bootHandler(evt) {
    registerMDNSListener("_raop._tcp")
}

void logMDNSEntries() {
    log.debug getMDNSEntries("_raop._tcp")
}
9 Likes