… 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 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
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().
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.)
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.
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.
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!
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.
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…