local devicesToCheck = { -- tabela kontrolowane czujniki + czas do pierwszego alarmu { ['name'] = 'Drzwi zew góra', ['threshold'] = 2 }, } local alertCount = 3 -- ilosc powiadomien return { on = { timer = {' at 21:55-06:30 every 2 minutes'}, }, logging = { level = domoticz.LOG_DEBUG, -- zmien na domoticz.LOG_ERROR, jak skrypt Ok marker = "Kontrola wejść" }, data = { ['Drzwi zew góra'] = {initial=0}, }, -- nie zmieniaj nic ponizej execute = function(dz) for i, deviceToCheck in pairs(devicesToCheck) do local name = deviceToCheck['name'] local threshold = deviceToCheck['threshold'] local state = dz.devices(name).state local minutes = dz.devices(name).lastUpdate.minutesAgo if ( state == 'Open') then dz.log('Device ' .. name .. ' staat ' .. minutes .. ' minuten open.') if (minutes > threshold) and (dz.data[name] < alertCount) then dz.data[name] = dz.data[name] + 1 dz.notify('Przypominam Otwarte ', name .. ' jest ' .. minutes .. ' minut otwarte.', dz.PRIORITY_HIGH) dz.log(' otwarte zbyt długo ' .. tostring(dz.data[name])) end elseif (dz.data[name] > 0) then dz.notify('Informuję ', name .. ' już zamknięte.', dz.PRIORITY_HIGH) dz.log('Device ' .. name .. ' jest ' .. minutes .. ' zamknięte') dz.data[name] = 0 end end end }