Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local devicesToCheck = {
- {
- ['name'] = 'Test', --Geef hier de naam van het apparaat op
- ['startAfter'] = 0, --Na hoeveel minuten moet de eerste waarschuwing komen?
- ['warnings'] = 3 --Hoeveel waarschuwingen wil je ontvangen?
- },{
- ['name'] = 'Test2',
- ['startAfter'] = 0,
- ['warnings'] = 4
- }
- }
- local messageWarnings = {
- ['0'] = 'eerste waarschuwing',
- ['1'] = 'tweede waarschuwing',
- ['2'] = 'derde waarschuwing',
- ['3'] = 'vierde waarschuwing',
- ['4'] = 'vijfde waarschuwing'
- }
- return {
- on = {
- timer = { 'every 5 minutes' },
- },
- data = {
- ['Test'] = { initial=0 }, --Voer hier EXACT de zelfde namen als boven in (in devicesToCheck) in!
- ['Test2'] = { initial=0 }
- },
- execute = function(domoticz)
- for i, deviceToCheck in pairs(devicesToCheck) do
- local deviceName = deviceToCheck['name']
- local numberOfWarnings = deviceToCheck['warnings']
- local currentDeviceState = domoticz.devices(deviceName).state
- local lastDeviceUpdate = domoticz.devices(deviceName).lastUpdate.minutesAgo
- local minutesToWait = deviceToCheck['startAfter']
- local deviceCounted = domoticz.data[deviceName]
- if ( currentDeviceState == 'Open') then
- if(deviceCounted < numberOfWarnings and lastDeviceUpdate >= minutesToWait) then
- domoticz.notify("Domoticz", deviceName .. " staat al " .. lastDeviceUpdate .. " minuten open. Dit is de "..messageWarnings[''..deviceCounted..''].."", domoticz.PRIORITY_NORMAL,domoticz.SOUND_DEFAULT, "" , "telegram")
- end
- domoticz.data[deviceName] = domoticz.data[deviceName] + 1
- elseif( currentDeviceState == 'Closed' and deviceCounted > 0) then
- domoticz.data[deviceName] = 0
- domoticz.log("De deur is dicht")
- domoticz.notify("Domoticz", deviceName .. " is al " .. lastDeviceUpdate .. " minuten dicht.", domoticz.PRIORITY_NORMAL,domoticz.SOUND_DEFAULT, "" , "telegram")
- end
- --end
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment