Please test and share the log.
Set Light to On based on motion detection between time [Solved]
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Set Light to On based on motion detection between time
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: Set Light to On based on motion detection between time
If I understand you correctly this is what should do that.
Code: Select all
return
{
on =
{
devices =
{
[26] = { 'between 00:00 and sunrise' },
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Camera',
},
execute = function(dz, item)
local light = dz.devices('Voordeurlamp')
local offDelay = 300
if item.active then -- state == 'On'
light.cancelQueuedCommands()
light.switchOn()
light.switchOff().afterSec(offDelay)
end
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: 178
- Joined: Tuesday 07 June 2016 22:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Netherlands
- Contact:
Re: Set Light to On based on motion detection between time
Thanks again Waaren for this quick response.
Will test this and give feedback.
Will test this and give feedback.
-
- Posts: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Set Light to On based on motion detection between time
I have this when it's dark:waaren wrote: ↑Wednesday 23 September 2020 9:04Like this?Code: Select all
return { on = { timer = { 'at sunset', 'at sunrise', }, }, logging = { level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK marker = 'lights at night', }, execute = function(dz) local light = dz.devices(42) if dz.time.matchesRule('at sunrise') then light.switchOff() else light.switchOn() end end }
Code: Select all
if (domoticz.devices(145).lux >= 0) and (domoticz.devices(145).lux <= 850) then
if domoticz.devices(147).state == "On" and -- iDetect - Anyone
domoticz.devices(3).state == "Off" and -- Virt_SLEEP
domoticz.devices(4).state == "Off" and -- Virt_TV
domoticz.devices(5).state == "Off" then -- Virt_Manuell
domoticz.devices(25).dimTo(60) -- Storarum: Golv
domoticz.devices(26).dimTo(60) -- Storarum: Tak
domoticz.devices(45).dimTo(40) -- Storarum: LED
domoticz.devices(101).dimTo(100) -- Storarum: Hue 1
domoticz.devices(102).dimTo(100) -- Storarum: Hue 2
domoticz.devices(101).setKelvin(45) -- Storarum: Hue 1
domoticz.devices(102).setKelvin(45) -- Storarum: Hue 2
domoticz.devices(93).dimTo(50) -- Storarum: Gardin LED
end end
But it's two scripts for each environment script for each room.
And a bit of hassle when I need to update the script.
But I would love to find a way to have it in one script.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Set Light to On based on motion detection between time
Please share both complete scripts. What happens and when might be clear for you as creator of the scripts but it is not for me.Melotron wrote: ↑Wednesday 23 September 2020 10:50 I have this when it's dark:
And a similar script with .setKelvin(75) that's starting at 19:00 to 09:00. It's working quite ok with two scripts for it.
But it's two scripts for each environment script for each room.
And a bit of hassle when I need to update the script.
But I would love to find a way to have it in one script.
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: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Set Light to On based on motion detection between time
Or would this work?
local Kelvin ['at 18:01-07:00'] = 75, ['at 07:01-18:00'] = 45
domoticz.devices(101).setKelvin(Kelvin)
local Kelvin ['at 18:01-07:00'] = 75, ['at 07:01-18:00'] = 45
domoticz.devices(101).setKelvin(Kelvin)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Set Light to On based on motion detection between time
No that is not the right syntaxis.
use something like
Code: Select all
local Kelvin = domoticz.time.matchesRule('at 18:01-07:00') and 75 or 45 -- 75 during nighttime and 45 during day
domoticz.devices(101).setKelvin(Kelvin)
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: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Set Light to On based on motion detection between time
Thanks alot.waaren wrote: ↑Wednesday 23 September 2020 11:54No that is not the right syntaxis.
use something likeand please have a look at the dzVents wiki. It is there to help youCode: Select all
local Kelvin = domoticz.time.matchesRule('at 18:01-07:00') and 75 or 45 -- 75 during nighttime and 45 during day domoticz.devices(101).setKelvin(Kelvin)
I've been looking there and its been a good help for me, but a few things like this with local and a few other things are hardly mentioned there.
I've also been looking for a good kelvin scale to convert 3000 and 7000, I have found by trial and error that 75 are almost 3000 and 45 are fairly close to 7000 lol
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Set Light to On based on motion detection between time
dzVents is Lua. A good start to understand the Lua syntax can be found here and here
If you found something that is dzVents and not in the wiki then please feel free to propose a new or better text. I'm more then happy to improve the wiki where needed.
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
Who is online
Users browsing this forum: No registered users and 0 guests