Motion Light Off after 2 minutes at Nighttime
Moderator: leecollings
Motion Light Off after 2 minutes at Nighttime
I'm looking for a script that will turn the hallway light off after no motion for 2 minutes only when its nighttime out.
Searched the forums but didnt really see what I was looking for..
Searched the forums but didnt really see what I was looking for..
-
- Posts: 550
- Joined: Tuesday 17 June 2014 22:14
- Target OS: NAS (Synology & others)
- Domoticz version: 4.10538
- Location: NL
- Contact:
Motion Light Off after 2 minutes at Nighttime
Sorry wrong answer
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Re: Motion Light Off after 2 minutes at Nighttime
Ehhh figured it out using smart lua scripts. I think.
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
can you give some examples for others browsing the forum with a similar question?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
From the dzVents wiki:
"A device trigger can have a time-rule constraint: on = { devices = { ['myDevice'] = 'at nighttime' } }. This only triggers the script when myDevice was changed and the time is after sunset and before sunrise."
so if you use this as the on = section and something like
Code: Select all
if trigger.state == "On" then
domoticz.devices("hallway light").switchOn().checkFirst()
else
domoticz.devices("hallway light").switchOff()
end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
waaren wrote: ↑Friday 31 August 2018 19:37From the dzVents wiki:
"A device trigger can have a time-rule constraint: on = { devices = { ['myDevice'] = 'at nighttime' } }. This only triggers the script when myDevice was changed and the time is after sunset and before sunrise."
so if you use this as the on = section and something likein the execute = section (assuming the motion detector switches to "Off" after two minutes.) If that is not the case the script becomes a bit more complicated with either a uservar or openURL .Code: Select all
if trigger.state == "On" then domoticz.devices("hallway light").switchOn().checkFirst() else domoticz.devices("hallway light").switchOff() end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 38
- Joined: Friday 17 March 2017 9:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Netherlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
@Warren : That solution will not work.
He wanted to switch off a light when there is no motoin (so no device trigger).
A solution that I use is to use a timed event (my PIR check runs every minute). So a solution might be.
No sure if the time-rule works with a timer. (might try this)
on = {
timer = {'[Every minute ', 'at nighttime' ]}
He wanted to switch off a light when there is no motoin (so no device trigger).
A solution that I use is to use a timed event (my PIR check runs every minute). So a solution might be.
Code: Select all
return {
active = true,
on = {
timer = {'Every minute '}
},
execute = function(domoticz)
if ( ( domoticz.devices('PIR Hallway').lastUpdate.minutesAgo => 2 ) and (domoticz.devices('Hallway').state == 'On' and domoticz.time.isNightTime)) then
domoticz.devices('Hallway').switchOff()
end
end
on = {
timer = {'[Every minute ', 'at nighttime' ]}
RFXCom(E) - Yeelight Lights - KaKu / Alexa HA Bridge
Windows 2012 / Windows 2012R2 / Xpenology/ Pi 3 / Milight / Home build ESP8266 / Sonoff
Windows 2012 / Windows 2012R2 / Xpenology/ Pi 3 / Milight / Home build ESP8266 / Sonoff
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
As always .. It depends

My motion detectors also trigger an event after the set time folowing a motiondetection passed.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 14
- Joined: Friday 25 November 2016 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Motion Light Off after 2 minutes at Nighttime
For me this works perfectly. Maybe u can use it. This way the lights stay on for 1 minute after motion sensor detected motion.
Verstuurd vanaf mijn Moto G (5) Plus met Tapatalk
Code: Select all
return { on = { devices = {motion sensor} },
execute = function(domoticz, device)
local light = domoticz.devices(light u want to switch)
if ((not light.active and device.active) or (light.active and device.active)) then
light.switchOn()
elseif (not device.active) then light.switchOff().checkFirst().afterMin(1) end
end }
Who is online
Users browsing this forum: No registered users and 1 guest