return { on = { devices = { 'Lampki Wiatrołap', -- nazwa wlacznik w domoticz 'Czujka Pir Wiatrołap' -- nazwa czujnika w domoticz } }, data = { warunek = { initial = false }, }, logging = { level = domoticz.LOG_DEBUG, marker = 'PIR Lampa', }, execute = function(dz, item) local maxSeconds = 30 local motion = dz.devices('Czujka Pir Wiatrołap') -- nazwa czujnika local switch = dz.devices('Lampki Wiatrołap') -- nazwa włacznika if item == motion then -- detekcja aktywna if motion.active and not switch.active then -- detekcja wyzwala skrypt dz.data.warunek = true switch.cancelQueuedCommands() switch.switchOn().checkFirst() elseif motion.active and switch.active and dz.data.warunek == true then switch.cancelQueuedCommands() elseif not motion.active and dz.data.warunek == true then switch.switchOff().afterSec(maxSeconds).checkFirst() end elseif item == switch and item.active and not motion.active then dz.data.warunek = false end end }