Page 1 of 2
Set for X minutes, but I want light when motion is still ON
Posted: Friday 18 April 2014 11:22
by AndyRoosendaalNL
Hi all,
I am using Blocky; When I detect motion, I want to set the light on for 1 minutes. No problem sofar.
But after 1 minute, the light is switched off, even when I'm still in the room. That's just the way the [Set for X minutes] works.
What I want is the light to be on for let's say 1 minute, until motion is no longer detected. Only then should the light switch off after 1 minute.
For example; I have Garden lights which switch on when I am in the garden. I don't want them to switch off every minute, and then me waving at the PIR
.
So what I am looking for is;
When I detect motion, I want to set the light on for 1 minutes.
When motion is detected again (PIR is still giving the ON status) the timer should reset to 0 and start counting again.
Is this even possible in Blocky???
Re: Set for X minutes, but I want light when motion is still
Posted: Friday 18 April 2014 12:19
by simonrg
I don't believe you can do what you want with Blockly, as if the light is on then you can't turn it on again, so the light has to go off, before you can turn it on again.
Using Lua it is possible to script exactly this action, by having one script which turns the light on and a seperate timer script which turns the light off after the motion sensor has not been activated for a set number of minutes. Have a look at this wiki page for details -
http://www.domoticz.com/wiki/Smart_Lua_Scripts.
Re: Set for X minutes, but I want light when motion is still
Posted: Friday 18 April 2014 18:25
by bizziebis
It's possible with blocky. Just add another (dummy) switch witch will switch off after 1 minute (it's a setting of the switch) and call it for example 1 Min Timer (in my example)
- blocky.jpg (139.82 KiB) Viewed 15220 times
(sorry for the big image, my tablet has a high dpi setting)
Every time the PIR detects motion the timer will be activated again and starts counting down from 60 seconds. Until the last movement is detected, then the light will go off.'
You can do a lot of nice stuff with blocky, just think a little further than the standard blocks
Re: Set for X minutes, but I want light when motion is still
Posted: Friday 18 April 2014 18:39
by Keptenkurk
Smart Lua Scripts now under Domoticz concepts in the Wiki...
/paul
Re: Set for X minutes, but I want light when motion is still
Posted: Friday 18 April 2014 18:47
by simonrg
Neat piece of Blockly, takes quite some reading, nice logic -
It appears that "dummy" switches are treated differently to "physical" switches, as you are relying on switching your "1 minute timer on" while it is already on, which is inconsistent with not being able to skip the dummy switch and just do it for the light with 1 minute to off and multiple ons -
Or am I missing something obvious
Re: Set for X minutes, but I want light when motion is still
Posted: Tuesday 22 April 2014 18:48
by AndyRoosendaalNL
Thanks all for the input.
I have installed the extended Smart Lua Script, and I am still testing the enviroment.
A question about the script_device_pirs :
I have a dummy switch in Domoticz for a nighttime, which starts 1,5 hours earlier than the actual sundown time. Now I want the x in PIRxrzSwitchName also to accept a check on the switch, instead of the custom timer, so I have added:
-- x specifies when the PIR controls - a=all day, n=nighttime, d=daytime,
-- 1=custom timer 1 set to 22:00 to 07:30
-- s=Dummy-Nightime (Dummy switch set in Domoticz which controls manual set day-nighttime)
In the script I have added:
function timetest(opertime)
if opertime == "a" then
return true
end
if opertime == "n" then
if timeofday['Nighttime'] then
return true
else
return false
end
end
if opertime == "d" then
if timeofday['Daytime'] then
return true
else
return false
end
end
if opertime == "s" then
if (otherdevices['Dummy-Nightime'] == "On") then
return true
else
return false
end
end
if opertime == "1" then
time = os.date("*t")
return customtest(time.hour, time.min, 22, 0, 7, 30)
end
return false
end
My question, (as I am completely new to lua), is the opertime="s" if...then... part correct??
Re: Set for X minutes, but I want light when motion is still
Posted: Tuesday 22 April 2014 19:09
by simonrg
Your code is fine, it should work, I will add it as extension to the wiki page I created -
http://www.domoticz.com/wiki/Smart_Lua_Scripts
Nice idea of a way to extend the script and a good example of the flexibility of Domoticz. My only thought is that you could end up with lots of dummy switches and forget what they are, but this is not likely as you won't want many. My other thought is encode something in the Dummy switches name, not sure what.
In general the ultimate test is does it work? If you don't see any errors in the log and it does what it should then it is right.
Simon
Re: Set for X minutes, but I want light when motion is still
Posted: Wednesday 23 April 2014 12:06
by AndyRoosendaalNL
Thank you for your reply.
The obvious disadvantage using the dummy switch of course, is the 'hard coded' switch name. It's name in the script will not change when you change the name in Domoticz causing errors. And also, for every switch you want to include, you will need an additional IF THEN code with its correct switch name.
But for me, it is working. (I only have 1 dummy switch at this moment, to overcome the sundown time. It's already almost dark in my house at sundown time, so this is my workaround.
Re: Set for X minutes, but I want light when motion is still
Posted: Wednesday 23 April 2014 12:42
by simonrg
Your code looks good.
I am warming to the dummy switch idea and it needn't require recoding for each new switch.
Thinking out loud for groups:
- PIRsg4Sundown would activate group Sundown only if DummySundown was on.
PIRsg2CatInHouse would activate group CatInHouse only if DummyCatInHouse was on.
PIRsg0GarageDoorClosed would activate group GarageDoorClosed only if DummyGarageDoorClosed was on.
You get the idea.
Re: Set for X minutes, but I want light when motion is still
Posted: Wednesday 23 April 2014 13:26
by simonrg
Actually using dummy switches makes life a lot simpler, so I have taken out the custom timing options and replaced it with the general version of your dummy switch idea.
The modified script is now on the wiki -
http://www.domoticz.com/wiki/Smart_Lua_ ... ied_Coding
Re: Set for X minutes, but I want light when motion is still
Posted: Wednesday 23 April 2014 13:45
by AndyRoosendaalNL
Even better! Great going Simon.
Re: Set for X minutes, but I want light when motion is still ON
Posted: Sunday 26 June 2016 21:09
by micbou
did you ever get this to work? I'm looking to do the same thing
Re: Set for X minutes, but I want light when motion is still ON
Posted: Sunday 26 June 2016 22:17
by micbou
So with the blocky below the lights turn on when the amount of lux < 15 and motion is detected on one of the motion sensors (works). The 2 minute timer has a 120 sec delay on 'off' and even though a new motion is detected and the '2 minute timer' switch gets updated, all lights still turn off after the initial 120 seconds.
Any suggestions/ideas?
- Schermafbeelding 2016-06-26 om 22.12.38.png (142.39 KiB) Viewed 13160 times
Re: Set for X minutes, but I want light when motion is still ON
Posted: Sunday 26 June 2016 22:30
by Derik
try to remove the 3 event.
Re: Set for X minutes, but I want light when motion is still ON
Posted: Sunday 26 June 2016 22:45
by micbou
Got it to work!
- Schermafbeelding 2016-06-26 om 22.44.37.png (120.8 KiB) Viewed 13146 times
Re: Set for X minutes, but I want light when motion is still ON
Posted: Wednesday 09 November 2016 20:27
by Tjenko
Hi.
This simple Blockly code is working
Re: Set for X minutes, but I want light when motion is still ON
Posted: Wednesday 14 December 2016 19:06
by abductor
Tjenko wrote:Hi.
This simple Blockly code is working
Thanks for the tip! Will try it. I was doing something complicated where I had a separate blocky script that would turn off after x seconds of motion but it would always trigger and not get reset if there motion in between the interval.
Re: Set for X minutes, but I want light when motion is still ON
Posted: Sunday 12 February 2017 10:51
by freijn
Re: Set for X minutes, but I want light when motion is still
Posted: Wednesday 20 September 2017 20:40
by jjnj
bizziebis wrote: ↑Friday 18 April 2014 18:25
It's possible with blocky. Just add another (dummy) switch witch will switch off after 1 minute (it's a setting of the switch) and call it for example 1 Min Timer (in my example)
blocky.jpg
(sorry for the big image, my tablet has a high dpi setting)
Every time the PIR detects motion the timer will be activated again and starts counting down from 60 seconds. Until the last movement is detected, then the light will go off.'
You can do a lot of nice stuff with blocky, just think a little further than the standard blocks
Sorry to revive an old topic, but using this method every time the timer is set to on, it will detect the second blockly row, see that the timer is set on, and set it on again:
Code: Select all
2017-09-20 20:38:11.735 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:11.737 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:11.974 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:11.984 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:12.209 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:12.222 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:12.230 (RFXCOM) Temp (Unknown)
2017-09-20 20:38:12.415 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:12.417 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:12.606 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:12.608 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:12.806 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:12.808 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:13.017 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:13.020 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:13.227 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:13.229 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:13.438 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:13.441 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:13.650 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:13.652 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:13.863 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:13.866 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:14.075 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:14.077 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:14.286 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:14.295 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:14.528 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:14.532 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:14.723 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:14.725 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:14.933 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:14.943 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:15.072 Hardware Monitor: Fetching data (System sensors)
2017-09-20 20:38:15.152 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:15.156 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
2017-09-20 20:38:16.235 EventSystem: Event triggered: Moodlight voortuin_2
2017-09-20 20:38:16.238 (Dummy) Lighting 2 (Timer 1 minuut voortuin)
What can be used as a workaround?
*Edit, changed the off timer of the sensor
Re: Set for X minutes, but I want light when motion is still
Posted: Saturday 12 May 2018 1:45
by wizpt
bizziebis wrote: ↑Friday 18 April 2014 18:25
It's possible with blocky. Just add another (dummy) switch witch will switch off after 1 minute (it's a setting of the switch) and call it for example 1 Min Timer (in my example)
blocky.jpg
(sorry for the big image, my tablet has a high dpi setting)
Every time the PIR detects motion the timer will be activated again and starts counting down from 60 seconds. Until the last movement is detected, then the light will go off.'
You can do a lot of nice stuff with blocky, just think a little further than the standard blocks
Sorry for getting back to this..but I'm new here, and I'm digging everything eheheh
I tried the sequence you posted and everything worked fine. The only problem i have is that when i try to turn on the light manually, I can't. I think is because when turned on automatically I get "sensor off + timer off + light on"...what makes the light go off.
Thanks for any help.