We have moved at community.getvera.com

Author Topic: I'd like to light a lamp plugged into the outlet when my son this up at night  (Read 1389 times)

Offline neoloop

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Good morning.
I have a 2 vera.
I have a motion sensor and a 3 in 1 made ​​elctrique controlled by vera.
I'd like to light a lamp plugged into the outlet when my son this up at night.
and the day the lamp will not light.
can you tell me if the code is good luup?

if (luup.is_night ()) then
  return false
end
local Device3 = 14
local RandOnTime3 = 3600
DelayOn3 function ()
luup.call_action ("urn: upnp-org: ServiceId: SwitchPower1", "setTarget" {newTargetValue = "1"}, Device3)
luup.call_timer ("StayOn3", 1, On3, "", "")
end

best regards

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
It sound like you're interested in turning a light on for a few minutes when motion is detected?
Have you considered using the available events (i.e. no code) to accomplish (most of) this? You could then add the luup.is_night() bit to only run it at night.
Dezwaved at the moment...

Offline neoloop

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
Good morning.
yes thank you, I changed the code put in luup by the following:
luup.is_night return () == true

I have to create a scene and add a command, then add an event sensor (doorr / windows) IS luup tripped and code?
Is that correct?

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Yes. You could create two separate scenes, one for On and one for Off, if you can control the delay / on-time of your sensor. The sensor will then notify Vera when it's tripped, and when it's not tripped anymore. Vera can then turn the light on/off in response to those events.

See if you can get that to work, then add the luup.is_night part.
« Last Edit: December 06, 2011, 09:36:26 am by oTi@ »
Dezwaved at the moment...