Author Topic: Looping Question  (Read 220 times)

Offline Tony-Memphis

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +0/-0
Looping Question
« on: May 04, 2017, 11:14:05 am »
In my startup lua, I run a scene every couple of minutes.  In that scene's LUUP, I make some checks (daylight vs. sunset, etc.).  I return true or false based on the conditions. 

So, my question is, once the scene is "on," I am still looping every couple of minutes.  So, does that mean the scene is reactivated every couple of minutes while the conditions equate to true? 

What I am doing is looking at a light sensor for 30 minutes before sunset.  If it is dark, I turn the lights outside on.  It just occurred to me this morning though that during that 30 minutes, I might be activating the scene over and over? 

It works great, but I am just wondering if it is not a good practice to activate the scene every couple of minutes.  Seems like I read that it doesn't do anything unless the state changes, but I can't remember.

Thanks for the help,

Tony

Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9297
  • Karma: +697/-128
    • RTS Services Plugins
Re: Looping Question
« Reply #1 on: May 04, 2017, 01:07:22 pm »
Why not just run your scene at  15 minutes after sunset (Done with an Input Schedule)

Adjust the 10 minutes to more (Darker before turning on the light)  or less (lighter before turning on the light)
Unless you are in the high latitudes this should work well all year.
 

Offline Tony-Memphis

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +0/-0
Re: Looping Question
« Reply #2 on: May 04, 2017, 02:09:31 pm »
Sorry I didn't make what I was doing clear maybe?  I have a schedule setup to turn the lights on at sunset.  On a cloudy day (like today), I want to turn the lights on a bit earlier since it is dark before sunset due tot he cloud cover.  So, I check for that 30 min. window and if the sensor is on/off and then turn the lights on if it is within the 30 before sunset and it is dark. 

I was just wondering since I am running the scene every couple of minutes, if it keeps sending the swith an ON signal?

Thanks,

Tony

Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9297
  • Karma: +697/-128
    • RTS Services Plugins
Re: Looping Question
« Reply #3 on: May 04, 2017, 03:29:01 pm »
If the scene LUA returns true it will run the device commands associated with the scene.

I have never had good look with light level sensors .. slow to respond and their repeatable accuracy is not very good.
That's why I only use a time relative to sunrise or sunset.

Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9297
  • Karma: +697/-128
    • RTS Services Plugins
Re: Looping Question
« Reply #4 on: May 04, 2017, 03:34:04 pm »
Does your light sensor have a trirgger for LUX < XXX

Then you could have one scene with two triggers to turn on the light:
    1) The Schedule
    2) The LUX trigger. (My Light sensors have this  trigger)

You would not need any LUA code.




Offline Tony-Memphis

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +0/-0
Re: Looping Question
« Reply #5 on: May 04, 2017, 03:35:11 pm »
Thanks. 

Me neither!  I bought one and it broke!  So, I built my own.  I used an op amp to create a Schmitt trigger attached to a photodiode.  A variable resistor is used to adjust to the darkness level you want to define as "dark."  That circuit is attached to a Z wave switch via the low voltage wires that you normally connect to a normal wall toggle.  So, when the light hits the set point, the switch goes off (or on -whichever you prefer - mine is ON = day).  So, I just grab the status of the switch to see if it is dark r light.  Been working great for quite a while now.  Since it is a toggle, I reset it every night at 3am (in case there was a power outtage - I know it is dark at 3am!).

I am working on some code now to check the status of the module in question and if it is already on, do nothing. 

Thanks!

Tony

Online RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9297
  • Karma: +697/-128
    • RTS Services Plugins
Re: Looping Question
« Reply #6 on: May 04, 2017, 04:16:32 pm »
Great .. you can use the event for when the z-wave switch changes state to trigger the scene.

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 507
  • Karma: +11/-4
Re: Looping Question
« Reply #7 on: May 04, 2017, 08:59:12 pm »
Sorry I didn't make what I was doing clear maybe?  I have a schedule setup to turn the lights on at sunset.  On a cloudy day (like today), I want to turn the lights on a bit earlier since it is dark before sunset due tot he cloud cover.  So, I check for that 30 min. window and if the sensor is on/off and then turn the lights on if it is within the 30 before sunset and it is dark. 

I was just wondering since I am running the scene every couple of minutes, if it keeps sending the swith an ON signal?

Thanks,

Tony

I use the Weatherunderground plug-in to get weather data and set up 6 schedules - lights on at sunset if clear, lights on at 15 min before sunset if cloudy, and lights on at 30 min before sunset if raining. Same for lights off - sunrise if clear, sunrise +15 min if cloudy, and +30 if raining.

I have been thinking of one day adding an exterior light meter. Then exterior lights could be on at 2 in the afternoon if I get a gully washer.
Vera 3, UI7 1.7.919, CT101 t-stat, Everspring motion detector, GE/Jasco switch, Leviton outlet, AeonLabs door sensor, Insteon garage control, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual & Multi Switch, Weather, Sys. Mon.