The Vera Community forums have moved!

Advanced => Programming => Scene Scripting => Topic started by: col8eral on May 25, 2018, 07:30:54 am

Title: How do I get status of virtual switch
Post by: col8eral on May 25, 2018, 07:30:54 am
I have been trying to get the status of a virtual switch.  I have tried all of the following without any luck

local WaterStatus = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "GetStatus", device)

local WaterStatus = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1", "Poll", {}, device)

local WaterStatus = luup.variable_get("Service: urn:upnp-org:serviceId:SwitchPower1", "GetStatus", device)

Where am i going wrong?
Title: Re: How do I get status of virtual switch
Post by: rigpapa on May 25, 2018, 09:07:34 am
I have been trying to get the status of a virtual switch.  I have tried all of the following without any luck

local WaterStatus = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "GetStatus", device)

In this version, your variable name is incorrect. It's should be just Status.

Quote
local WaterStatus = luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1", "Poll", {}, device)

In this version, you're trying to do a variable GET using luup.call_action()s arguments, which won't work. Your first example shows a bit of that confusion as well, I think.

Quote
local WaterStatus = luup.variable_get("Service: urn:upnp-org:serviceId:SwitchPower1", "GetStatus", device)

This would be correct, again if you just used Status instead of GetStatus. The reason you can use either the VSwitch1 service or the SwitchPower1 service is that the VSwitch plugin defines and maintains both, which is a good convenience on its part, if not redundant. Either will work, though, given the right service name and variable name.

Getting and setting of variables are not actions. They're just getting and setting. So when fetching a variable, don't prefix its name with "Get", and likewise when trying to set a value, don't prefix the variable name with "Set".
Title: Re: How do I get status of virtual switch
Post by: col8eral on May 25, 2018, 09:43:58 am
Thank you so much for taking the time to give such a detailed answer. That was really helpful.