Author Topic: Stop PIR switching on lights during the day  (Read 566 times)

Offline BrianVickers

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Stop PIR switching on lights during the day
« on: August 09, 2017, 05:48:00 pm »
Apologies for the ultra Newbie question. I have an outdoor PIR switching on outdoor lights. I obviously do not want the lights to come on during the day, so I have installed the Day or Night Plug in. I have set up a scene to turn on the lights with two triggers one when the PIR detects movement and the second when Day or Night indicates night.This does not work, the PIR fires the lights Day or Night.
I rather assumed that the logic works as: IF a PIR event is fired AND the state of Day or Night is Night THEN switch on the lights. The alternative way it may work is ; IF a PIR event is fired AND Day or Night changes state to Night THEN switch on the Lights, But in the latter case the light would never fire?
I am sure that I can fix this with LUUP or, more likely PLEG but in the first instance would like to understand what I am doing wrong with the basic triggers.
Thanks for any help

That's  if I can get pased the FOUR am I a human questions

Online zedrally

  • Hero Member
  • *****
  • Posts: 865
  • Karma: +2/-0
  • Black Cat Controllers & Control Systems
    • Black Cat Control Systems
Re: Stop PIR switching on lights during the day
« Reply #1 on: August 09, 2017, 06:42:23 pm »
Use PLEG.


Have a read of PLEG BAsics to get a general idea, then start by fiddling.


http://forum.micasaverde.com/index.php/topic,21997.0.html
Living in the Land of Oz, give me a vegemite sandwich. Home Seer, Vera Lite & Edge, Popp, Black Cat Smart Hub & Vera G, Black Cat Lite 1 & 2's a Black Cat Dimmer or 2, then some  Black Cat Cat's Eye PIR's & Door-Window Sensors plus a Z-UNO or 2.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Stop PIR switching on lights during the day
« Reply #2 on: August 09, 2017, 06:54:03 pm »
As to your question, the triggers are OR'd.  AND has been missing for a very long time, but there is now a hint of it if you use the iOS app or you load the latest AltUI.  It is also entirely possible to make conditional AND behavior with lua code.

And, as @zedrally mentions, PLEG can do this quite well.

Offline BrianVickers

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Stop PIR switching on lights during the day
« Reply #3 on: August 10, 2017, 06:01:03 am »
Thanks for the help, PLEG it is then.

It does seem a bit odd that such a straightforward requirement can't be done out of the box. Ah well.

The other oddity is that if the triggers are OR'd then I would expect the lights to go on at Night when the Day and Night triggers a change to Night, which it doesn't.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Stop PIR switching on lights during the day
« Reply #4 on: August 10, 2017, 12:56:08 pm »
The other oddity is that if the triggers are OR'd then I would expect the lights to go on at Night when the Day and Night triggers a change to Night, which it doesn't.
That is odd.  If the trigger is set up correctly, it should indeed trigger on the change to night.  Nothing in the log when the transition to night occurs and this scene should fire?  Of course you may not want to spend time to track this down if you are switching to PLEG.

Offline BrianVickers

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Stop PIR switching on lights during the day
« Reply #5 on: August 11, 2017, 08:01:52 am »
I am interested in tracking it down, but not too sure how to progress further, There are no Logs shown against the Day or Night plug in, my loaction is set up correctly and, most curiously, the scene triggers the lights when I change the Day or Night to Night. The scene only turns on the lights for 10 minutes so it is possible I have missed it. I will extend the time the the lights stay on so will check tonight.

(The ludicrous level of Am I robot control, is putting me off posting however)

Offline Priest

  • Full Member
  • ***
  • Posts: 142
  • Karma: +5/-0
Re: Stop PIR switching on lights during the day
« Reply #6 on: August 11, 2017, 08:44:11 am »
If you dont care about setting specifically for DAY/NIGHT but want to restrict for time you can limit the times a trigger will be acted on in the trigger setup.  you could also just use the lua code luup.is_night() as part of a function to fail or not fail the scene. 

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9741
  • Karma: +737/-136
    • RTS Services Plugins
Re: Stop PIR switching on lights during the day
« Reply #7 on: August 11, 2017, 08:53:29 am »
Try to POWER cycle your Vera.

Offline BrianVickers

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Stop PIR switching on lights during the day
« Reply #8 on: August 11, 2017, 04:20:11 pm »
Thanks once again Guys.

First of all My Bad, the lights are being triggered by the Day or Night Plug in - not that that us the behaviour I wanted - but at least that is a mystery solved and a behaviour  understood.

I could use schedules and may well do pro-tem until I work out an alternative fix, but really want the scene to align with the hours of dusk.

All fixable in due course - that Luup snippet looks as if it would be useful -  but right now need to focus on other issues. I hadn't really picked up that all this stuff is still closer to the hobbiest than the mainstream.

Online zedrally

  • Hero Member
  • *****
  • Posts: 865
  • Karma: +2/-0
  • Black Cat Controllers & Control Systems
    • Black Cat Control Systems
Re: Stop PIR switching on lights during the day
« Reply #9 on: August 11, 2017, 07:52:16 pm »
Thanks once again Guys.

First of all My Bad, the lights are being triggered by the Day or Night Plug in - not that that us the behaviour I wanted - but at least that is a mystery solved and a behaviour  understood.


So can you tell us what behaviour you had expected or want?
Initially you asked for lights to come on at Dusk, now you are saying it isn't what you expected.
Living in the Land of Oz, give me a vegemite sandwich. Home Seer, Vera Lite & Edge, Popp, Black Cat Smart Hub & Vera G, Black Cat Lite 1 & 2's a Black Cat Dimmer or 2, then some  Black Cat Cat's Eye PIR's & Door-Window Sensors plus a Z-UNO or 2.

Offline Juppers

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +2/-1
Re: Stop PIR switching on lights during the day
« Reply #10 on: August 12, 2017, 02:55:51 am »
Thanks for the help, PLEG it is then.

It does seem a bit odd that such a straightforward requirement can't be done out of the box. Ah well.

The other oddity is that if the triggers are OR'd then I would expect the lights to go on at Night when the Day and Night triggers a change to Night, which it doesn't.

It can be done out of the box with some simple luup code. http://forum.micasaverde.com/index.php/topic,18679.0.html or http://forum.micasaverde.com/index.php/topic,18679.msg141962.html#msg141962 are simple examples of how to do it without pleg.



Offline rotbard

  • Newbie
  • *
  • Posts: 3
  • Karma: +1/-0
Re: Stop PIR switching on lights during the day
« Reply #11 on: August 12, 2017, 04:05:14 am »
I use  "Combination Switch" app
You can Combination few rules like light level+PRI

I think "AND" function should be basic in Vera...

Offline BrianVickers

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: Stop PIR switching on lights during the day
« Reply #12 on: August 12, 2017, 06:59:17 am »
Thanks once again Guys.

First of all My Bad, the lights are being triggered by the Day or Night Plug in - not that that us the behaviour I wanted - but at least that is a mystery solved and a behaviour  understood.


So can you tell us what behaviour you had expected or want?
Initially you asked for lights to come on at Dusk, now you are saying it isn't what you expected.

I wanted the Garden lights to come on when the PIR detects motion, but only at night. My initial assumption was that Triggers works as AND not OR. Apologies if that was not clear.

(Clearly this can be done but needs Luup or add-ons)

Offline jswim788

  • Hero Member
  • *****
  • Posts: 538
  • Karma: +29/-2
Re: Stop PIR switching on lights during the day
« Reply #13 on: August 12, 2017, 09:48:50 am »
I wanted the Garden lights to come on when the PIR detects motion, but only at night. My initial assumption was that Triggers works as AND not OR. Apologies if that was not clear.

(Clearly this can be done but needs Luup or add-ons)
This particular one can be done quite easily with one line of lua in your scene.  Set up the trigger for motion and have the scene turn on the lights, and put this in your scene lua code:
Code: [Select]
return luup.is_night()
If you use the iOS app, then AND is built in (no add-on needed).  And supposedly this will appear soon for the other interfaces.  (But why wasn't this there from the beginning?)

For more sophisticated logic there are multiple paths to explore: PLEG, more advanced lua, AltUI's workflows, rules engine, etc.

Offline lvandeusenii

  • Sr. Newbie
  • *
  • Posts: 35
  • Karma: +0/-0
Re: Stop PIR switching on lights during the day
« Reply #14 on: August 30, 2017, 06:28:17 pm »
i use the is_night LUA script and I combine it with a countdown timer.  this works really well.