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?
[quote=“col8eral, post:1, topic:199200”]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)[/quote]
In this version, your variable name is incorrect. It’s should be just [tt]Status[/tt].
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.
local WaterStatus = luup.variable_get("Service: urn:upnp-org:serviceId:SwitchPower1", "GetStatus", device)
This would be correct, again if you just used [tt]Status[/tt] 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”.
Thank you so much for taking the time to give such a detailed answer. That was really helpful.