Hi, I’m new to luup development, although i’ve coded some in other languages (c++, vb). what i would like to happen is for a light to turn on when the door is unlocked, but only if it’s between sunset and sunrise. if anyone could point me to a sample or some sort it would be much appreciated.
That link will certainly help in setting up luup events or scenes, but I’ve looked for this myself and have not found how to determine “sunset” or “sunrise” in the luup code. Is there a variable such as “sunrise=1” to know if that has occurred or not?
For sunset/sunrise see http://forum.micasaverde.com/index.php?topic=2073.msg8132#msg8132.
ok, i see where these are going. maybe i could approach it a slightly different way. my “front porch light” will only be on if “sunset” scene has triggered, so maybe i could do something to the effect of only turn this lamp on if “front portch light” = on type of thing?
i’m going to play around with it a bit. thanks for everyone’s input.
well, i think i got this working pretty well, except that i’ve had a little trouble with my scenes in general since updating to the luup release. hopefully that will shake itself out and my porch lights will when i get home tonight.
Excellent. I hope your way is lighted tonight.
Care to share the scene code you used?
doesn’t look like i have it foolproof yet. i’ll have to link the code when i get home, the upgrade seems to have busted my findvera access. looks like right now it’s basically running the scene whether the front porch light is on or not
i’ll like code later.
so this is all i’m trying to do. i have this code put in the “luup scene” button
local lul_porch = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“GetStatus”,29)
luup.log("The front porch light is: " … lul_porch)
if (lul_porch==“1”) then
return true
end
problem seems to be that the scene always evaluates to true, whether the light is on or not. i have tried switching lul_porch==“0” and scene still runs.
i don’t know where the “luup.log” is located to see what the variable value is reporting back as. seems like this should be easy
The few examples I’ve tinkered with it seems that if it falls through, it returns “true”.
Have you tried:
if(lul_porch==0) then
return false
end
mpenda is correct - you have to explicitly “else return false” in your code to prevent the scene from executing.
you know, i was wondering about that. thanks a bunch i’ll try it now.
looks like that did it. Thanks a bunch!
final bits…
local lul_porch = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,29)
if (lul_porch == “0”) then
return false
end
What did you do for the sunrise/sunset aspect of the scene?
the front porch light is setup in a different set of scenes and comes on at sunset, and off at sunrise. rather than messing with sunrise or sunset, i simply query the status of this light. it should only be on after sunset and before sunrise.
Ah. That’s MUCH simpler.
Thanks.
I noticed with my Intermatic switches, if the bulb is burned out, the switch will not turn on. So testing if a switch is ON may not be foolproof. Somewhere else in the forums, I saw Luup code for sunrise/sunset. Just something to think about
Are you talking about an Intermatic lamp module or a wall switch? From what I read, the plug in lamp modules need to have something plugged in to work. I haven’t had much experience with the wall switches, but I know wall outlets work fine with or without something plugged in.
The sunrise/sunset code is quite complex. I’m hoping they’ll expand the scenes a bit more.
A pseudo device would work as well, but arming and bypassing them from the scenes doesn’t seem to work just yet.
@LVinci,
If you are talking about in-wall switches w/o neutral line, then that’s the way they work - they need to have an incandescent load to close the circuit and get power for the Z-Wave radio…
the device i’m querying status for is an in wall switch, not a plug in module. i’m very happy with it so far, as I know have a scene to turn lights on for me when i come in the front door and it’s dark outside, which is all i wanted