Directly control WeMo switches (Arduino 2 Photon Code)

I am using your code and it works great! (thanks) I wonder if you also know how the code would look if you had more than one (1) WEMO device, and I would like to get the friendly name as well.
Michael

1 Like

Hi @mgcurtis,

Glad the code was useful for you! Took a little futzing to get it working so I’m glad it saved you a little time.

You are definitely right that I didn’t write it to support multiple WEMOs on the same LAN. I believe that in order to support that you will need to parse the setup.xml file to get information on the devices including friendly name.

Once you get that HTTP response from the WEMO you will see a LOCATION line. This line gives you the IP address of the device but also the url for the device’s setup.xml If you make a request to that address using something like the HTTP Client you can get all that XML information. I did not dig too deep on the community here but I bet someone has an XML parser class which could be used to extrapolate device specific information from the XML like the Friendly name.

Hopefully I will have time in the near future to proceed further on this project. I would like to build a WEMO class library for Photon which will discover devices and let you instantiate objects for all discovered devices. I think that would be useful for many Particle users and it could be easily ported to Arduino I’m sure.

I thought I should touch back with some follow-up. It turns out that:
searchPacket.concat(“urn:Belkin:device:controllee:1”); will only return outlet types,
searchPacket.concat(“urn:Belkin:device:lightswitch:1”); only returns light switch types, but
searchPacket.concat(“urn:Belkin:device:1”);
will return all Belkin devices.

3 Likes

Good to know @mgcurtis Thanks for sharing!