[ST Edge] mDNS for Edge: LAN service discovery

Multicast DNS (mDNS) is a way to advertise and discover services on your home LAN. Many devices and applications support this specification, making it possible to integrate these services using a SmartThings Edge driver. Today, SmartThings Edge doesn’t offer a built-in API for mDNS, although it may sometime in the future. So I’m making two things available for those who want to explore this now:

  1. An mDNS Lua library that allows Edge driver developers to quickly and easily utilize mDNS to discover supporting devices & applications
  2. A demonstration driver that uses this library to allow you to explore mDNS-enabled services on your LAN

mDNS Library
This Lua library provides a simple API to allow developers to integrate mDNS-supporting devices and applications without having to become an expert in DNS or mDNS. This is available for inclusion in your hub package at my github here. There is also complete documentation of how to use it.

mDNS Demonstration Driver
This Edge driver is available on my test channel. When an Add device / Scan nearby devices command is done in the mobile app it will add one new device labeled “mDNS Discovery”. Open the device to the device details screen and you can perform the discovery actions outlined in the instructions below.

Note that anyone can try out this driver - it is intended for use by anyone, not just developers. No mDNS expertise needed!

To install the driver, use this channel invite link, enroll your hub, and choose to install the mDNS Tester driver.

I’m looking forward to any feedback you want to provide here.

Instructions for using the Demonstration Driver

I recommend you follow the sequence below the first time you try this…

  • (1) Get a list of all available service types on your LAN:
    Simply select the "Execute a query" button and tap “List Service Types”. The mDNS Response field will show a numbered list of service types found on your LAN.

  • (2) List all available service “instances” for a particular service type:
    In the list returned from above, decide what service type you want to explore and note its row number. Then tap the button at the top of the device details screen labeled “Choose response record for query type”. This button will copy whatever row of data from the mDNS Response list into the query input field below. (Sorry the row list is not in order - that is a SmartThings bug). Tap the desired row number and note that that response record will be copied in to the field labeled “Manually edit query input”. Now tap the “Execute a query” button and select “Get Services Instances”. You will now get a list of all service instances found on your LAN for that particular service type.

  • You can now get some selected bits of information for a particular service instance. Use the “Choose response record for query input” button as before to select one of the service instances listed. Then for the query to execute, try “Get Hostnames”. Select a hostname as before and then try “Get IP Only”.

Additional info

mDNS queries are sensitive to the precise query name used, and not using the right format will result in no data returned.

To get an IP-only address, sometimes it will work with the instance name, but other times it will require the hostname. Try it both ways.

For full addresses, which include a port number, you must use the full instance name.

Once you know what you are doing, you can try typing the query input directly into the “Manually edit query input” field. (The ability to copy select records into this field is provided as a convenience)

For more information on how this all works, see my github readme file.


:+1: for this library. I did some early prototyping with it and it works very well.

1 Like

Lol…another example of something I wasted loads of time on before finding Todd’s excellent work,

I wonder if being able to advertise an ip address and port for an http endpoint for a driver would be useful? I don’t think the library currently does this does it?

I’d currently like to create a virtual device with a http server and advertise its address.