Page 1 of 1
lua help newbee
Posted: Tuesday 30 March 2021 12:00
by rolandtwilt
Hi, I am looking for a sript but I don't know where to start. I have a twilight switch, a motion detector and a floodlight. And now I would like the spotlight to come on when there is movement in the garden and it is dark. The individual components all work well, but how do I make them work together. I tried a blocky but it doesn't work well. Can someone help me? thank you in advance
Re: lua help newbee
Posted: Tuesday 30 March 2021 12:48
by waaren
rolandtwilt wrote: ↑Tuesday 30 March 2021 12:00
Hi, I am looking for a script but I don't know where to start. I have a twilight switch, a motion detector and a floodlight. And now I would like the spotlight to come on when there is movement in the garden and it is dark. The individual components all work well, but how do I make them work together. I tried a blocky but it doesn't work well. Can someone help me? thank you in advance
in dzVents (100% Lua) it could look below
__________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
___________________________________________________________________________________________________________________________
Code: Select all
return
{
on =
{
devices =
{
'motion detector', -- change to name of your motion detector device
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
marker = 'Motion at night',
},
execute = function(dz, item)
local isDark = dz.devices('twilight').active -- change to name of twilight switch
local spotLight = dz.devices('floodlight') -- change to name of spotlight / floodlight
if item.active and isDark then
spotLight.switchOn()
spotLight.switchOff.afterSec(60) -- switch Off after 1 minute
end
end
}
Re: lua help newbee
Posted: Wednesday 31 March 2021 13:27
by rolandtwilt
It works, I am happy! Very much thought, super!
