Set for X minutes, but I want light when motion is still ON

Moderator: leecollings

AndyRoosendaalNL
Posts: 4
Joined: Monday 07 April 2014 12:13
Target OS: Linux
Domoticz version:
Contact:

Set for X minutes, but I want light when motion is still ON

Post 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 :mrgreen: .

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???
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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
blocky.jpg (139.82 KiB) Viewed 15210 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 ;)
User avatar
Keptenkurk
Posts: 103
Joined: Wednesday 21 August 2013 17:24
Target OS: -
Domoticz version:
Location: Waalre, The Netherlands
Contact:

Re: Set for X minutes, but I want light when motion is still

Post by Keptenkurk »

Smart Lua Scripts now under Domoticz concepts in the Wiki...
/paul
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Set for X minutes, but I want light when motion is still

Post by simonrg »

Neat piece of Blockly, takes quite some reading, nice logic - :o

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 - :shock:

Or am I missing something obvious :oops:
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
AndyRoosendaalNL
Posts: 4
Joined: Monday 07 April 2014 12:13
Target OS: Linux
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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??
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
AndyRoosendaalNL
Posts: 4
Joined: Monday 07 April 2014 12:13
Target OS: Linux
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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.
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
AndyRoosendaalNL
Posts: 4
Joined: Monday 07 April 2014 12:13
Target OS: Linux
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still

Post by AndyRoosendaalNL »

:D Even better! Great going Simon.
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post by micbou »

did you ever get this to work? I'm looking to do the same thing
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post 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
Schermafbeelding 2016-06-26 om 22.12.38.png (142.39 KiB) Viewed 13150 times
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post by Derik »

try to remove the 3 event.
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post by micbou »

Got it to work!
Schermafbeelding 2016-06-26 om 22.44.37.png
Schermafbeelding 2016-06-26 om 22.44.37.png (120.8 KiB) Viewed 13136 times
Tjenko
Posts: 1
Joined: Wednesday 09 November 2016 1:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post by Tjenko »

Hi.
This simple Blockly code is working
Attachments
Domoticz Motion.JPG
Domoticz Motion.JPG (25.04 KiB) Viewed 12351 times
abductor
Posts: 10
Joined: Tuesday 03 November 2015 18:32
Target OS: -
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post 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.
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Set for X minutes, but I want light when motion is still ON

Post by freijn »

jjnj

Re: Set for X minutes, but I want light when motion is still

Post 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
wizpt
Posts: 1
Joined: Saturday 12 May 2018 0:19
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Set for X minutes, but I want light when motion is still

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest