I am trying to create a dzVents script which sends notifications to telegram/Domoticz Log after a Switch is turned ON/OFF.
There must be 4 posibilities:
1. Switch ON -->Notification send (this works)
2. Switch ON -->Notification send 15 minutes after switch is turned ON (not working yet)
2. Switch ON -->Notification send 60 minutes after switch is turned ON (not working yet)
4. Switch OFF -->Notification send (this works)
Here is what I have sofar:
Code: Select all
-- Frietpan dzVents script
return
{
on = { devices = {'Test'}},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Test Schakelaar',
},
execute = function(dz, item)
local token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
local chatid = XXXXXXXXXXXXXXX
local msgAan = 'De frietpan is aangezet!'
local msgKlaar = 'De frietpan is klaar om te frituren!'
local msgWordt = 'De frietpan staat nog aan en wordt nu uitgezet!'
local msgUit = 'De frietpan is uitgezet!'
if (item.state == 'On') then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgAan..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
dz.log(msgAan,dz.LOG_DEBUG)
elseif (item.state == 'On' and "time is 15 minutes later after switch is turned ON") then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgKlaar..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
dz.log(msgKlaar,dz.LOG_DEBUG)
elseif (item.state == 'On' and "time is 60 minutes later after switch is turned ON") then
item.switchOff();
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgWordt..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
dz.log(msgWordt,dz.LOG_DEBUG)
elseif (item.state == 'Off') then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..msgUit..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
dz.log(msgUit,dz.LOG_DEBUG)
end
end
}How does this work in dzVents?