Using Luup code with WeMo Plugin

Hi All,

I have two WeMo Minis working with the WeMo plugin. Basic functionality is great: I can see the two devices as switches in UI7, and can write scenes to turn them on and off. I can also link to them with Alexa; and can even see them in ImperiHome (which doesn’t have a WeMo interface). But I’d like to move a little further with them …

I have Aeon MiniMotes scattered around the house to control lighting and such. A MiniMote has 8 button press events: long and short presses with each of the 4 buttons. I’m using the MiniMotes to turn the WeMo devices on and off, but the remote is pretty crowded at this point, and I wish that I didn’t need to dedicate separate buttons of On and Off functions.

For many of the ‘regular’ Z-Wave devices, there is a toggle function in the Luup code, which works great with HADevice1 elements. This allows one remote press to turn something on, and then a second press of the same button turns it off. It doesn’t seem to work with WeMo devices, though – or I haven’t figured out the syntax to make the Luup calls. Can anyone help?

Regards,
-BW

The toggle action is defined here:

http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions#HaDevice1

But whether it works for your device, I don’t know.

Thanks for the reply. I’m aware of the toggle function you mention. It does not seem to work for the WeMo device – at least, not in the several ways that I’ve tried it. So, I’m looking to write my own. In theory, a toggle function of a binary device is pretty straightforward: one polls for the state (on/off), then sends a command to go to the opposite state. But I would need to better understand the variables and calls that the WeMo plugin supports to write it.

I guess the first question is: does a WeMo Mini act as a HaDevice1, in all aspects? My suspicion at this point is, “No, it doesn’t.” I tried to access the device as a HaDevice1, using its device number – nothing happened at all. Then, I parsed the XML file for the device, and substituted its address – again, nothing. Of course, I could be totally misunderstanding the syntax of the device and commands; or there could be some other piece missing. Does anyone have an API for the WeMo device?

Regards,
-BW

The MiniMote is acting as a scene controller? I.e., a short button is linked to a scene? And in that scene you are telling the WeMo to turn on or to turn off?

If you look in the advanced options for the WeMo does it have a variable called Status? And what’s the ServiceId associated with it (when you hover your mouse over the variable)?

I’ll take a guess that it matches a standard switch, so possibly you could use this (untested) Lua code in your scene:

local dID = 5 -- use the device ID of your WeMo local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",dID) if status == "1" then -- turn it off if it is on luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, dID) else -- turn it on if it is currently off luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, dID) end return true
Note that your scene won’t need any explicit actions - the above Lua code does the action for you

The WeMo plugin doesn’t implement the HaDevice1 ToggleState action. When I wrote the plugin that action wasn’t well specified (it probably still isn’t).

Anyone who feels like hacking the code (it’s on GitHub) to add this feature is welcome to have a go at it and send me a pull request. I reckon it would be about 20 lines of code.

Did anyone ever write this up? I was able to get my Wemo to be seen as a device but when I turn it ON, the status stays OFF even though the Wemo does turn on. Was it ever written?