local devicesToCheck = { -- table with doors to check and the minutes before the first warning is given { ['name'] = 'Stan Bramy', ['threshold'] = 20 }, } -- number of times you are warned about an open door local alertCount = 3 return { on = { timer = {'every 2 minutes'}, }, logging = { level = domoticz.LOG_INFO,ERROR, marker = "kontrola" }, -- count per door of the number of alerts per door data = { ['Brama Garaż'] = {initial=0}, }, execute = function(domoticz) for i, deviceToCheck in pairs(devicesToCheck) do local name = deviceToCheck['name'] local threshold = deviceToCheck['threshold'] local state = domoticz.devices(name).state local minutes = domoticz.devices(name).lastUpdate.minutesAgo if ( state == 'Open') then domoticz.log('Device ' .. name .. ' staat ' .. minutes .. ' minuten open.') if (minutes > threshold) and (domoticz.data[name] < alertCount) then domoticz.data[name] = domoticz.data[name] + 1 domoticz.notify('Przypominam Otwarta ', name .. ' jest ' .. minutes .. ' minut otwarta.', domoticz.PRIORITY_HIGH) domoticz.log(' otwarta zbyt długo ' .. tostring(domoticz.data[name])) end elseif (domoticz.data[name] > 0) then domoticz.notify('Informuję ', name .. ' już zamknięta.', domoticz.PRIORITY_HIGH) domoticz.log('Device ' .. name .. ' jest ' .. minutes .. ' zamknięta') domoticz.data[name] = 0 end end end }