We have moved at community.getvera.com

Author Topic: Scene to turn light on if door unlocked, only between sunset and sunrise  (Read 25276 times)

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
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.

Offline wseverino

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 854
  • Karma: +0/-0
  • Da Man, Da Myth, Da Legend - in his own mind!
My ZWave Network: Too friggin big to list.....

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #2 on: October 18, 2009, 09:15:26 pm »
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?
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #4 on: October 19, 2009, 04:37:32 pm »
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.
« Last Edit: October 19, 2009, 04:42:03 pm by kristinaw »

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #5 on: October 20, 2009, 06:39:50 pm »
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.

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #6 on: October 21, 2009, 09:22:17 pm »
Excellent. I hope your way is lighted tonight.
Care to share the scene code you used?
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #7 on: October 22, 2009, 01:38:47 pm »
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.

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #8 on: October 26, 2009, 03:27:33 pm »
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 :/

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #9 on: October 26, 2009, 07:16:17 pm »
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
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #10 on: October 26, 2009, 08:18:46 pm »
@kristinaw,

mpenda is correct - you have to explicitly "else return false" in your code to prevent the scene from executing.
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #11 on: October 27, 2009, 10:11:18 am »
you know, i was wondering about that. thanks a bunch i'll try it now.

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #12 on: October 27, 2009, 10:26:39 am »
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

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #13 on: October 27, 2009, 11:18:18 am »
What did you do for the sunrise/sunset aspect of the scene?
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline kristinaw

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Re: Scene to turn light on if door unlocked, only between sunset and sunrise
« Reply #14 on: October 27, 2009, 12:26:38 pm »
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.