In my attempt to further automate my home, I’m trying to create UPnP devices for my appliances. The simplest examples are power switches and lights that can be controlled using the UPnP protocol. Obviously that’s not very user friendly, so I decided to experiment with a webinterface for the interaction, while keeping the UPnP functionality. The UPnP part can then be connected to the RFXcom devices for actually controlling my X10 and HomeEasy equipment (still working on my DevCom project for the hardware connection part)
As a test case I recreated the NetworkLight example that’s included in the Developer tools for UPnP. Firstly I converted it to Visual Basic, as that’s my preferred language. While doing that I also noticed that the example was incomplete, the device showed itself as a ‘Binary Light‘ to the world, evenhough it included dimming capabilities. So that’s been updated to, now its a ‘Dimmable Light‘ and it has all the required items implemented.
As to my webinterface experiment (first ever webpage I programmed as such), I added the same lightbulb image as the application itself has, with several controls to control it. Clicking on the image will switch power on/off, and setting the load or the step size will invoke the appropriate UPnP methods underlying. To try the interface, click the link to the presentationpage, which will open in a browser window. Then in the browser click the image or modify the load, to see that both the web interface and the application window respond to the changes.
The web page part is pretty crap, will need some serious improvements there. Would be nice if individual devices would render their small control pages into a larger webpage, so multiple controls can be combined to create a central control panel for my home. No idea what that will take, jQuery, iframes, or both? also touch support for iOS and Android devices would nice. There is a need to learn on that part.
PS. Creating the linklabel on the application window took some effort. The UPnP library does not expose the base address a device is located on. So if the full URL is http://127.0.0.1:3820/WebUI/index.html, then only the ‘/WebUI/index.html’ part could be retrieved. Hence I modified the UPnP library to be able to extract the IP address and port number as well (I noticed that this doesn’t work on IPv6 because of missing [ ] brackets). The modified library is included in the source.
The example can be downloaded here, sourcecode is included (downloaded 308 times).