[ST Edge] UPnP Control Point Driver

I’d like to share a project I’ve developed that provides a complete and robust UPnP control point library for writing Edge drivers. The audience for this package is developers that want to integrate LAN devices supporting the UPnP specification (partial or complete), as well as anyone else that is looking to learn how to use the new Edge platform to integrate LAN-based devices in general.

The package includes an example driver that you can use to explore and interact with existing UPnP devices on your LAN. SmartThings devices are created during discovery, and select UPnP attributes can be viewed on the device details screen in the mobile app. You never know what you may find on your LAN; I was personally able to find 14 devices that support UPnP on my home network (e.g. routers/extenders, IP cameras, streaming devices, smart TVs, Philips Hue hub, etc).

The package also includes a template file for writing your own driver using the UPnP library.

The library supports all UPnP 2.0-specified functions, including SSDP (discovery), device alive monitoring, event subscription, and control commands, as well as access to all UPnP device and service description data. The example driver demonstrates all of these capabilities.

Thorough documentation is available at this link. This is a good place to start if you want to determine if this package is for you.

The code is being distributed via github here: https://github.com/toddaustin07/edge_upnp

Caveat: Since Edge is still in beta, expect this package to evolve as fixes & adjustments are made in the underlying platform. However I intend to keep the library API constant to minimize any changes needed to drivers.

To anyone interested in trying this package out, I’m looking forward to your comments and feedback.

12 Likes

Great work @TAustin I will be sure to use this to help me learn all the cogs in the drivers setup.

1 Like

Very interesting project. I’d be interested to try this but not before it is available to install through channel. It’ll nice to know what this could find in my apartment. :thinking::grinning_face_with_smiling_eyes:

1 Like

Thanks for your comment! I’m initially distributing this through git since it’s really meant to be a library for developers rather than a turn-key driver for end-users. However I will explore the idea of turning the included example driver into more of a turn-key driver anyone could install via a channel just to do a ‘UPnP survey’ of their LAN.

UPDATE:

I’ve had to make an update to the git package since I just found out that my package config file required some updates for the beta release (this was developed primarily during alpha). So please, if you tried this already and couldn’t get it to work, pull the latest package again to get the update and you should be good to go.

I get your point. Just let me know if you’re about to publish this through channel. I’ll be first to enroll.:blush:

1 Like

@Sakari and others with interest…

I have created a version of the example driver and published it via a channel as you suggested. This is the first time I’ve attempted this, so please let me know if this works for you or if you have problems.

I’m calling this example driver a ‘UPnP Explorer’, as it will identify all available devices and sub-devices supporting UPnP on your LAN. A detailed description of this driver, including how to decipher log messages, is available in the documentation link in my original post above.

Here is the invitation: SmartThings. Add a little smartness to your things.

I would recommended firing up a logging window so you can see the details of what is happening as the driver executes: once you finish using the web link above to install the driver from my channel to your hub, you can use the CLI to find out the driver ID and then start the logger:

smartthings edge:drivers:installed
smartthings edge:drivers:logcat <driverID> --hub-address=<hub ip addr>

You can then proceed to the mobile app and do an Add device->Scan nearby to initiate the UPnP device search. If you have any available, SmartThings devices will be created for each UPnP device found, with some selected UPnP attributes available to view on each device details screen.

Regarding the device details screen: As noted in the documentation, the Sequence Number will increment only for devices that were successfully subscribed-to. Expiration date is only updated when subscription events are received. For more complete realtime monitoring, see the log output.

If this ignites further interest in customizing the example or writing your own driver, the example code and UPnP library is all available on github per my original post.

I have been curiously following the Edge diver developments. So I connected to your channel to see how it works.
When I ran scan nearby it created 2 devices for my router: Actiontec “Broadband Router” and Lan Device. They both appear as switches. They are shown as on line but appear to have no function.
It was very easy to do.

1 Like

I found lot’s of stuff. Xbox, router, tv, etc. These kind of drivers have endless options and gives another dimension to SmartThings. Good start so far.

1 Like

Hi Paul - Thanks for trying it out! The SmartThings devices that get created are generic and all have switches. If your devices support subscriptions and send regular events then you’d see the switch toggle on or off each time a event is received, and the sequence number would increment. To really explore the services and commands that you could send to control the devices, you’d have to take a look at the device and service description XML and start customizing the driver for meaningful interaction. This driver blindly tries to subscribe to the first available service and doesn’t really try to actually control the device (that could be dangerous! :smirk:). See the documentation link for more info on all this. If you want to investigate further, I’d definitely recommend monitoring your log during discovery, watching for the XML retrieval URLs and then plugging them into a browser. Then you can see the gory details of all the services, commands, and device states that are available for each of your devices.

if there was a way to dynamically construct SmartThings devices, I could build a driver that parses the UPnP device XML and creates a device with the custom commands and associated arguments needed to exercise the available device services. But this is where I intended the curious developer to take over…

Great to hear, @Sakari! Thanks for letting me know you’re having success. :+1:t3:

OMIGOD!!! This is amazing. I have just spent a week trying to re-invent this sigh. Ah well at least I have learnt a lot and once I gave up on Windows for a lua environment I quite enjoyed it.

I’ve only just found this so I haven’t got very far, but I’'ll probably be thanking you again in a few days!!!