Luup Code Help, Error (s)

I am wanting to create a NIGHT LIGHT setup.
I thought if I checked the status of my hall lights Devices ID’s #39 & #42, and using the "if Night"check, maybe I wouldn’t envertly cause the wife some grief!
But I am getting errors on my syntax,
Any and all help, will be appreciated.

– Find the status of four light switches
local Light1State= luup.variable_get(“urn:upnp-org:serviceId#39:Dimming1”, “LoadLevelTarget”, 3)
local Light2State= luup.variable_get(“urn:upnp-org:serviceId#42:Dimming2”, “LoadLevelTarget”, 3)
local Light3State=luup.variable_get(“urn:upnp-org:serviceId#43:SwitchPower1”,“Status”,?)
local Light4State=luup.variable_get(“urn:upnp-org:serviceId#46:SwitchPower2”,“Status”,?)

– Exit the scene if either of the lights are off and it is not dark out.
if (Light1State == “0”) or (Light2State == “0”) or not ( luup.is_night() ) then
return false
end

[quote=“RastusB2, post:1, topic:168600”]local Light1State= luup.variable_get(“urn:upnp-org:serviceId#39:Dimming1”, “LoadLevelTarget”, 3)
local Light2State= luup.variable_get(“urn:upnp-org:serviceId#42:Dimming2”, “LoadLevelTarget”, 3)
local Light3State=luup.variable_get(“urn:upnp-org:serviceId#43:SwitchPower1”,“Status”,?)
local Light4State=luup.variable_get(“urn:upnp-org:serviceId#46:SwitchPower2”,“Status”,?)[/quote]

You are messing with the service Id strings. Despite how they look, they are fixed strings that you can’t change.

Try this instead:

local Light1State = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", 39)
local Light2State = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelTarget", 42)
local Light3State = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",43)
local Light4State = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",46)

I’ve also moved your device IDs to the third argument. You’ll have to check that they are correct.

Thanks, futzie!

the arguement works for current daytime ( they lights didn’t come on) and I’ll have to wait till night time to see if it works then.
Also, I’ll need to check the string for (if on, exit)
That was a very quick response and I appreciate the help,

I adjusted the Luup as noted and I don’t receive a fault, but the sene will not run.

– Find the status of four light switches
local Light1State = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelTarget”, 39)
local Light2State = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelTarget”, 42)
local Light3State = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,43)
local Light4State = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,46)

– Exit the scene if either of the lights are on and it is not dark out.
if (Light1State == “0”) or (Light2State == “0”) or not ( luup.is_night() ) then
return false
end

What I was going for, was NOT turn off a light if it was already ON.
Shouldn’t the string have:

– Exit the scene if either of the lights are on and it is not dark out.
if (Light1State == “1”) or (Light2State == “1”) or not ( luup.is_night() ) then
return false
end

[quote=“RastusB2, post:3, topic:168600”]-- Exit the scene if either of the lights are on and it is not dark out.
if (Light1State == “1”) or (Light2State == “1”) or not ( luup.is_night() ) then[/quote]

The “and” in your comment became “or” in the code. That’s probably not right. How about:

if ((Light1State == "1") or (Light2State == "1")) and not ( luup.is_night() ) then

Note extra parentheses. “and” binds tigher than “or” so you need parentheses to force the “or” to happen first.

futzie;
Thanks, thats what it needed.
I guess I had “looked” at it so long, that I couldn’t see it anymore

The “and” in your comment became “or” in the code. That’s probably not right. How about:

Code:
if ((Light1State == “1”) or (Light2State == “1”)) and not ( luup.is_night() ) then

Note extra parentheses. “and” binds tigher than “or” so you need parentheses to force the “or” to happen first.