A kind soul provided me with this code, and it works fantastically.
However for one of my applications I require a twist, and have no clue where to begin, I have watched videos and read read stuff, but I personally cannot get a handle on either Lua or DZvents.
I would like to have Domoticz run this code as it is, but from say 23:00 hrs to 06:00 hrs when the "Bathroom MD Sensor" is activated the Dimmer "Bathroom" turns the light on at say 10% and at all other times outside of this the light will come on at around 90%
Many thanks
Code: Select all
return {
on = { devices = { "Bathroom MD Sensor" }
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "Bathroom Motion"
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(str,level or dz.LOG_DEBUG)
end
-- local Lux = dz.devices("Bathroom MD Lux").lux
local LuxDevice = dz.devices(450) -- <<<--- replace xxx by IDX of your Lux device
local Lux = LuxDevice.lux
-- local Lights = dz.devices("Bathroom")
local Lights = dz.devices(440) -- <<<--- replace xxx by IDX of your Bathroom lights
logWrite(LuxDevice.name .. " ==>> Lux: " .. Lux )
logWrite(Lights.name .. " ==>> State: " .. Lights.state)
logWrite(item.name .. " ==>> State: " .. item.state)
if Lux < 100 and item.state == "On" then
Lights.cancelQueuedCommands()
Lights.switchOn().checkFirst()
elseif item.state == "Off" and Lights.state == "On" then
Lights.switchOff().afterSec(300)
end
end
}