Cant even get LUUP code to turn on a switch to work

… And yes - The lowercase “n” made the difference!!

SO - I have NO IDEA why my device thinks literally every command is ‘unsafe’ but at least I can get it to work. Hopefully the rest of my network is otherwise protected well enough to not worry about it!

Thanks for all the help everyone!!

Thanks again… Now that I have this solved, your code for toggle worked great… Changed it for my device type:

local device=29
local switchOnOff = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", device)
    if (switchOnOff == "1") then
      -- Switch is on
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "0"},  device)
else 
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "1"},  device)
end
1 Like

Just to close the loop on this… the above command will change the variable, but have no effect whatsoever on the device. The only way to make a real (ZWave, etc.) device change is through luup.call_action().

Indeed, and there is already an action to toggle a switch, so you don’t have to write your own, see:

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

ServiceId is "urn:micasaverde-com:serviceId:HomeAutomationGateway1"

Action is ToggleState

1 Like

Yes the inbuilt “ToggleState” works for most Z-Wave devices. It does not work for my Philips Hue devices / AltHue plugin.

So I had to write the toggle Lua code to toggle Hue lamps in a scene.

However it is recommended to try the “ToggleState” function first in the Advanced Editor of a Vera scene.

Perhaps a “pretty please” to @amg0 could make this work…?

1 Like

One method I use to toggle Philips Hue lights involves first associating them with a virtual switch (from the Switchboard plug-in), and a routine within Reactor that turns the bulb on or off based on the virtual switch’s state.

In turn, I have a Reactor routine that simply toggles the virtual switch on/off (using [ToggleState]) every time I click a button on my battery-operated remote.

Simply arrangement. More versatile (e.g. easy to add other Hue bulbs or other devices to react to the virtual switch). Zero Luup needed! (I used to do it that way, myself.)

  • Libra

Well, this is odd, because I’ve just looked and all my MiniMote controller scenes use the ToggleState action, applied to lights controlled by the AltHUE plugin, and it all works just fine.

Maybe it works now then. When I added some coloured Hue bulbs to my lounge lamps last year it wasn’t working then for ToggleState.

I’ll try it again and see.

I just created a new Vera scene and added two Hue lamps with ToggleState action and it does indeed now work.

Perhaps it was with the Philips Hue 2 plugin it didn’t work with. As I did change to the Alt Hue plugin when the Philips Hue 2 plugin broke a while back.

1 Like

Really!? That’s good to know. It did change in the Vera console, but I didn’t go outside to see if the device (pool pump) actually turned on!! I did end up going back to the original command (which works with the lowercase “n”!) so I’ll have to test to make sure it’s working
Thanks!

1 Like

Good point! I hadn’t intended to suggest that my Toggle-ing method was necessary or some kind of “workaround”, when in fact it’s just the way I prefer to execute those functions. :wink:

I can confirm ToggleState action is implemented in ALTHUE plugin and works ( at least on my Hue devices )

the action is callable directly from ALTUI User Interface for instance

1 Like

It should be noted that the ToggleState action lives in service urn:micasaverde-com:serviceId:HaDevice1, so if one is already using the SetTarget action, which is in service urn:upnp-org:serviceId:SwitchPower1, and just changes the action name without also changing the service ID, it isn’t going to work, and I suspect that may be contributing to confusion happening here…

1 Like

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules