Re: Set Light to On based on motion detection between time
Posted: Wednesday 23 September 2020 9:28
Open source Home Automation System
https://forum.domoticz.com/
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
}
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
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.
No that is not the right syntaxis.
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)
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)