So i have a sensor on my front door when someone opens the door vera alerts sends me a push notification, and it also turns on 4 lights after 5 minutes it turns all the lights back off . This is all done by a scene i made and the front door sensor is the trigger for that scene.Now here is my problem i only want it to trigger the lights between the times of 6 Pm to 7 am. I do have the front door sensor set so it will only trigger the scene if the sensor is in the armed mode so i guess a simple way would be to put the front door sensor in bypass mode until 6 pm however if the sensor is in bypass mode i wont get a vera alert push notifications and i want those all the time . So what would be the best way to do this? i always want push notifications letting me know when someone comes in and out of the door, but only want the lights to trigger when its dark . I have no idea how to even start with the luup code and im guessing ill have to put some luup code on the front door trigger / sensor . Any help would be great thanks .
There is an example of the Luup code you want right here. Read the whole thread for an introduction to using Lua code in scenes.
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
@RexBeckett - You da man!
Edit: Also, see Programmable Logic Event Generator(PLEG) plugin.
okay so I put this luup code in the main luup and it didn’t work what am I doing wrong? also put it in the trigger luup and nothing didn’t work .
local pStart = “22:30”
local pEnd = “06:15”
local allow = true
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
[quote=“ryan219, post:4, topic:178948”]okay so I put this luup code in the main luup and it didn’t work what am I doing wrong? also put it in the trigger luup and nothing didn’t work .
local pStart = “22:30”
local pEnd = “06:15”
local allow = true
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end[/quote]
With those settings, the code will return true between 22:30 and 06:15 - so the scene will be allowed. Outside of those times the code will return false and the scene will not run.
How are you triggering the scene? Does the scene run when it shouldn’t or not run when it should?
So i got something working here im using this in my luup main code to only turn on lights at night time return luup.is_night() now my question is what does it specify as night ?
Also should this code still work if i change the times example below :
local pStart = “18:30”
local pEnd = “07:15”
local allow = true
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
Im using Schlage RS100HC V N N SL sensor
Thanks alot for the help !!
So i got something working here im using this in my luup main code to only turn on lights at night time return luup.is_night() now my question is what does it specify as night ?
luup.is_night() is true from sunset to sunrise - as predicted for your location. You could also use the DayorNight plugin (from the Mios app store) which allows you to set offsets to adjust your definition of night-time. See this post for how to use the DayorNight result in scenes.
Also should this code still work if i change the times example below :
You can change pStart and pEnd to any valid hh:mm time (24 hour clock). Your proposed values will allow the scene to run between 18:30 and 07:15.
Are you still having problems using this code in a scene?
I think it should be working now i just tested the scene by setting off the trigger for that scene and the lights did not come on. So hopefully tonight when i test it again they will come on at 5:30 pm. I change the code just a little to fit my needs . Code looks like this
local pStart = “17:30”
local pEnd = “07:15”
local allow = true
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min
if mEnd >= mStart then
return (((mNow >= mStart) and (mNow <= mEnd)) == allow)
else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)
end
Hopefully this will work out thanks alot for all your help !!!
The code worked great , Did what i wanted thanks again for the help.