return { on = { devices = { 'Łazienka', -- nazwa wlacznik w domoticz 'Czujka Pir Łazienka' -- nazwa czujnika w domoticz } }, data = { tylko_pir = { initial = false }, }, logging = { level = domoticz.LOG_DEBUG, marker = 'PIR Lampa', }, execute = function(dz, item) local maxSec = 20 local motion = dz.devices('Czujka Pir Łazienka') -- nazwa czujnika local switch = dz.devices('Łazienka') -- nazwa włacznika if item == motion then if switch.active and motion.active then if dz.data.tylko_pir then switch.cancelQueuedCommands() switch.switchOff().afterSec(maxSec).silent().checkFirst() end elseif motion.active and not switch.active then dz.data.tylko_pir = true switch.cancelQueuedCommands() switch.switchOn().forSec(maxSec).silent().checkFirst() end else -- switch if switch.active and not motion.active then dz.data.tylko_pir = false end end end }