]]-- return { on = { devices = { 'Garaż', -- nazwa wlacznik w domoticz 'Czujka Garaz ' -- nazwa czujnika w domoticz } }, data = { warunek = { initial = false }, }, logging = { level = domoticz.LOG_ERROR, marker = 'PIR Lampa', }, execute = function(dz, item) local maxSeconds = 10 local motion = dz.devices('Czujka Garaz') -- nazwa czujnika local switch = dz.devices('Garaż') -- nazwa włacznika if item == motion then -- detekcja aktywna if motion.state == 'On' and switch.state == 'Off' then -- detekcja wyzwala skrypt dz.data.warunek = true switch.cancelQueuedCommands() switch.switchOn().checkFirst() elseif motion.state == 'On' and switch.state == 'On' and dz.data.warunek == true then switch.cancelQueuedCommands() elseif motion.state == 'Off' and dz.data.warunek == true then switch.switchOff().afterSec(maxSeconds).checkFirst() end elseif item == switch and item.state == 'On' and motion.state == 'Off' then dz.data.warunek = false end end }