This was the Blockly I wanted to convert.

And this is the DzVents code I used.
Code: Select all
return
{
on =
{
timer =
{
'every 5 minutes',
},
devices =
{
'Daglicht',
'MS Zolder Overloop Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local dimmer = dz.devices('Lamp Zolder Overloop Dimmer')
local daglicht = dz.devices('Daglicht').state
local motion = dz.devices('MS Zolder Overloop Beweging').state
dz.log(dimmer.name .. ', state: ' .. tostring(dimmer.state) , dz.LOG_DEBUG)
dz.log('Daglicht, state: ' .. tostring(daglicht) , dz.LOG_DEBUG)
dz.log('MS Zolder Overloop Beweging, state: ' .. tostring(motion) , dz.LOG_DEBUG)
if dimmer.state ~= 'Off' and daglicht == Off and motion == On then
dimmer.dimTo(45).silent()
elseif dimmer.state ~= 'Off' and daglicht == Off and motion == Off then
dimmer.dimTo(20).silent().afterSec(150)
elseif dimmer.state ~= 'Off' and daglicht == On then
dimmer.dimTo(20).silent().afterSec(150)
dimmer.switchOff().afterSec(300)
elseif dimmer.state ~= 'Off' and dz.time.matchesRule('after 23:30' or 'before 6:30') and motion == Off then
dimmer.switchOff().afterSec(300)
end
end
}