Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local devicesToCheck = {
- -- table with doors to check and the minutes before the first warning is given
- { ['name'] = 'Xiaomi Tuindeur links', ['threshold'] = 3 },
- { ['name'] = 'Xiaomi Tuindeur rechts', ['threshold'] = 10 },
- }
- -- number of times you are warned about an open door
- local alertCount = 3
- return {
- active = true,
- on = {
- timer = {'every 5 minutes'},
- },
- logging = {
- -- level = domoticz.LOG_INFO,
- marker = "POR"
- },
- -- count per door of the number of alerts per door
- data = {
- ['Xiaomi Tuindeur links'] = {initial=0},
- ['Xiaomi Tuindeur rechts'] = {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("Domoticz", name .. " staat al langer dan " .. minutes .. " minuten open.", domoticz.PRIORITY_NORMAL,domoticz.SOUND_DEFAULT, "" , "telegram")
- domoticz.log('dit is waarschuwing ' .. tostring(domoticz.data[name]))
- end
- elseif (domoticz.data[name] > 0) then
- domoticz.notify("Domoticz", name .. " staat al langer dan " .. minutes .. " minuten open.", domoticz.PRIORITY_NORMAL,ddomoticz.SOUND_DEFAULT, "" , "telegram")
- domoticz.log('Device ' .. name .. ' is ' .. minutes .. ' dicht.')
- domoticz.data[name] = 0
- end
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment