UPnP gateway; third proof of concept

It’s been a while, but some major additions have been made to the UPnP gateway engine. Previously the engine would parse xml description files to generate objects. Now it includes both an xml factory and a device factory that generate everything on the fly.

The code now includes a BinaryLight and a DimmableLight (both standardized DCPs), they are based on standardized services SwitchPower and Dimming (also included). Implementing a fully functional DimmableLight device now only takes 4 lines of code;

-- create the device from a default implementation
device, err = upnp.devicefactory.builddevice("urn:schemas-upnp-org:device:DimmableLight:1", {
  friendlyName = "Dimmable NetworkLight 3 Lua test device",
  customList = {
    statetodevice = printstatus;

The promise of all this is that any device type needs to be coded only once, and can then be reused over and over again. Will be nice to implement the HEMS (Home Energy Management Systems) DCPs that are currently being developed on this engine as one of the initial implementations.

Please give the code a try. It’s fully functional, including dimming, ramping and stepping. Same as before, windows only, unpack and run the batchfile, then control through the UPnP DeviceSpy. Documentation is also available now from the github pages.

Here’s the download (downloaded 1177 times)

[ad name=”468×60 Banner”]


2 thoughts on “UPnP gateway; third proof of concept

  1. Hi Thijs

    Have you tried to use the UPnP gateway to issue commands to TVs or AV equipments to play some movie or song?
    I’m just thinking of a scenario where I would use LinKNX (that can call a lua script) on a KNX home automation project from where I could triger a certain song on its audio equipment, like Sonos for example, on arrival of the home owner.
    If you have, or try, some examples of this type of call please give details.

    • Not with this one. This gateway has for now only implemented devices, no controlpoint. UPnP makes a distinction between devices (that can be controlled) and controlpoints (that control devices).

      My previous gateway (based on .NET) bridges from UPnP to xPL, it allowed Girder to control UPnP devices. See this post.

      That said; the underlying UPnP library and the Lua binding for the new gateway do contain the controlpoint code, I just haven’t used/tested them yet. So aside from possible bugs in the binding code, it should be possible to control other devices through a Lua script.

      Depends on what it is exactly what you need (and probably on how familiar you are with UPnP and Lua)

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe without commenting