We have moved at community.getvera.com

Author Topic: Motion Detectors and Lights  (Read 23136 times)

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Motion Detectors and Lights
« Reply #15 on: January 22, 2014, 10:43:05 am »
You can do something like this:

light = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",18)

if(light == "0")then
  return true
else
  return false
end

As long as you have a scene that has the motion device as the trigger, you can add the above code into the luup section of the scene. Change "18" to the device number of the light. What this does is if the light is off, and the trigger of the motion is activated, the light will turn off. If the light is already on, it will not trigger the scene.

- Garrett

This works great..

I am reading about combining multiple conditions and don't have the formatting down right.
I would like to add to the above:

if (luup.is_night()) then
  return true
else
  return false
end

If I just add it in it errors... so I'm not sure how to add the night condition to the script  ???

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Motion Detectors and Lights
« Reply #16 on: January 22, 2014, 11:08:31 am »
I think your missing an "end" but i could be wrong as im no coding pro but you could give it a go whilst waiting for others to respond.

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Motion Detectors and Lights
« Reply #17 on: January 22, 2014, 11:11:30 am »
Both those chunks of code work by themselves
I just need to put them ion one LUUP script.


Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Motion Detectors and Lights
« Reply #18 on: January 22, 2014, 11:19:01 am »
ok, this may help or it may confuse things, this is a script which works fine on mine, you may be able to adapt to fit.

Code: [Select]
- device 34 is party mode switch
skip = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",34)
light51 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",51)
light51level = luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus",51)

if(skip=="1") or (luup.is_night())then
  return false
else
  -- 51 Hallway
if (light51 =="1") and (light51level =="100") then
return false
else
return true
end     

return true
end

Offline ryan219

  • Sr. Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
Re: Motion Detectors and Lights
« Reply #19 on: January 22, 2014, 06:04:16 pm »
so what does this do exactly?





ok, this may help or it may confuse things, this is a script which works fine on mine, you may be able to adapt to fit.

Code: [Select]
- device 34 is party mode switch
skip = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",34)
light51 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",51)
light51level = luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus",51)

if(skip=="1") or (luup.is_night())then
  return false
else
  -- 51 Hallway
if (light51 =="1") and (light51level =="100") then
return false
else
return true
end     

return true
end

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Motion Detectors and Lights
« Reply #20 on: January 23, 2014, 04:42:31 am »
essentially this is luup code which has to be met for my scene to run, I have a standard scene which uses triggers on no motion of the motion dectector and the light turns off after 3 minutes- however this will only happen if the luup code returns True. If the luup code returns false it doesn't matter that the scene has triggered - the scene will not run, essentially its figuring out if the light is already on but also if the light is at 100% (which i use as a manual override to stop motion sensors turning the lights out)

Stu

Offline RexBeckett

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3891
  • Karma: +483/-12
Re: Motion Detectors and Lights
« Reply #21 on: January 23, 2014, 05:27:15 am »
You can do something like this:

light = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",18)

if(light == "0")then
  return true
else
  return false
end

As long as you have a scene that has the motion device as the trigger, you can add the above code into the luup section of the scene. Change "18" to the device number of the light. What this does is if the light is off, and the trigger of the motion is activated, the light will turn off. If the light is already on, it will not trigger the scene.

- Garrett

This works great..

I am reading about combining multiple conditions and don't have the formatting down right.
I would like to add to the above:

if (luup.is_night()) then
  return true
else
  return false
end

If I just add it in it errors... so I'm not sure how to add the night condition to the script  ???

I think you want:

Code: [Select]
light = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",18)

if (light == "0") and luup.is_night() then
  return true
else
  return false
end

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Motion Detectors and Lights
« Reply #22 on: January 23, 2014, 09:23:39 am »
Thanks Rex, Works great!