luup code not working!

hello i have wirtten the following luup code on vera 3 using fibaro switches

local switchonoff = luup.variable_get(“urn:upnp-org:serviceId:RedLamp”,“Status”,9)
if (tonumber(switchonoff)==0) then
luup.call_action(“urn:upnp-org:serviceId:RedLamp”, “SetTarget”, {newTargetValue = “1”}, 9)
end

it check correctly and says it is executing but nothing is showing and the lamp is not turning on i didnt find any mistake in the code
can i get some help why it is not working?

How do you know the above is right?

the name RedLamp is the name i have given to the switch and the rest is from the xml i suppose i got it from the wiki

oh ok i understood now :smiley: thank you i have read the xml file it is SwitchPower1 it works fine now

How do you know the above is right?[/quote]
If go into the Advanced tab of the device and place your mouse over the variable it will display the serviceId that is recorded against it.

See example

http://forum.micasaverde.com/index.php?action=dlattach;topic=12825.0;attach=8134

thank you:D

Hi

I just want a trigger to turn a light on if its off, or off if its on, what could be simpler?

Please tell me what I am doing wrong.

Many thanks

local value = luup.variable_get(“urn:schemas-upnp-org:device:DimmableLight:1”, “Status”, 7)
if (value = “1”) then
luup.call_action(“urn:schemas-upnp-org:device:DimmableLight:1”, “SetStatus”, {NewStatus = “0”}, 7)
else luup.call_action(“urn:schemas-upnp-org:device:DimmableLight:1”, “SetStatus”, {NewStatus = “1”}, 7)

end

OK - you have a couple of problems:

urn:schemas-upnp-org:device:DimmableLight:1 is a device type. You need the service ID in this field.
Use: urn:upnp-org:serviceId:SwitchPower1

Status is the current state. The action needs to set the Target. Try: luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 7)

You might find this useful.

HI all

do you just want to set ON, or OFF trought a scene??

how can i do a scene doing the ON if the lamp its of
and OFF if the lamp its on!
just like a regular ON/OFF button
reason: want to use a macro + scene, to control 2 lights
the second light its IR controled!