Code: Select all
return {
on = {
devices = {'Test Switch'},
customEvents = {'Koffieapparaat*'}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "SvdP-koffie"
},
execute = function(domoticz, item)
domoticz.log('item.state = ' .. item.state, domoticz.LOG_DEBUG)
if (item.isDevice) then
if (item.state == 'On') then
domoticz.emitEvent('koffieapparaat12').afterSec(12)
domoticz.emitEvent('koffieapparaat28').afterSec(28)
domoticz.emitEvent('koffieapparaat30').afterSec(30)
end
elseif (item.trigger == 'Koffieapparaat12') then
local message = 'Het koffieapparaat is klaar voor gebruik'
message = string.gsub(message, "%s+", "+")
domoticz.openURL({ url = 'https://api.callmebot.com/whatsapp.php?source=domz&apikey=XXXXXX&phone=XXXXXXXXXXX&text=' .. message, method = 'GET'})
elseif (item.trigger == 'Koffieapparaat28') then
local message = 'Het koffieapparaat wordt automatisch uitgezet over 2 minuten'
message = string.gsub(message, "%s+", "+")
domoticz.openURL({ url = 'https://api.callmebot.com/whatsapp.php?source=domz&apikey=XXXXXX&phone=XXXXXXXXXXX&text=' .. message, method = 'GET'})
elseif (item.trigger == 'Koffieapparaat30') then
item.switchOff().checkFirst()
domoticz.log('Koffieapparaat gaat automatisch uit na een half uur.')
end
end
}