Trouble with Luup code

Hi,

I am currently trying to teach myself some basic Luup code. I have several things working but I’m struggling a bit with appliance modules. From what I can find in the Luup manuals, getting the status of an Appliance Module (HA02) should go something like this;

local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,7)
if( lul_tmp==“1” ) then
return false
end

The device number I’m trying to access is 7

I get a message in the Luup test window saying “bad device” and I can’t seem to get around it.

Can anyone see what I’m doing wrong?

Thanks,

Mark

It looks correct.

Do you have a screenshot of the Device’s “Dialog”, showing the Device # you’re using?

Did you get the device number from where it says Device #7 (see Capture1.png) or from the altid (see Capture2.png)? The correct device number is the one from Capture1.png (Device #7).

I got it from the “Device #7” at that top. I’ve also tried it on a couple of other devices, no joy.

Trying to post a screen shot but not having much luck.

The Device number field must be left empty for the code to work. Try again with the empty field and tell us if it worked.

Yep, worked now, thanks. I thought that field had to be populated (*).

Thanks again.

[quote=“MarkC, post:6, topic:168492”]Yep, worked now, thanks. I thought that field had to be populated (*).

Thanks again.[/quote]
Yeah, that one got me too when I first started with Vera!
Just cause it’s clearly noted: “* Required fields” doesn’t mean it’s required. As a matter of fact actually including the device ID in “* Required fields” box usually causes the test to fail ???

The more you use it the more you’ll see there’s lots and lots of bugs/misinformation in the control panel…

I removed the asterisk from there, but this will be seen only on newer firmware versions.

Is there any reason to even have a “device number” box at all… just asking?

If a device number is present, then the Lua code is run with that device’s Lua interface. Otherwise, it is run with the same interface as the code from Scenes. However, there seems to be a bug when a device number other than 0 is present. I asked Aaron about this and he’ll decide if we keep that field or not.

Honestly, I don’t know what are the advantages of running the code with a device’s specific interface, but I will try to find out.