Author Topic: How do I get status of virtual switch  (Read 383 times)

Offline col8eral

  • Sr. Member
  • ****
  • Posts: 354
  • Karma: +3/-2
How do I get status of virtual switch
« 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?

Online rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 761
  • Karma: +115/-1
Re: How do I get status of virtual switch
« Reply #1 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".
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3 sandbox.

Offline col8eral

  • Sr. Member
  • ****
  • Posts: 354
  • Karma: +3/-2
Re: How do I get status of virtual switch
« Reply #2 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.