Hi,
In order to call that function from any dzvents script I have put a helper in my global_data.lua (more info
Here
The content:
Code: Select all
telegram = function(domoticz, msg, destin)
local Msg = domoticz.urlEncode(msg)
local destin = string.lower(destin)
if destin == 'NAME1' then
local nmaURL = "https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id=CHATID1&text="..Msg.."&"
domoticz.openURL(nmaURL)
elseif destin == 'NAME2' then
local nmaURL = "https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id=CHATID2&text="..Msg.."&"
domoticz.openURL(nmaURL)
elseif destin == 'both' then
local nmaURL = "https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id=CHATID1&text="..Msg.."&"
domoticz.openURL(nmaURL)
local nmaURL = "https://api.telegram.org/bot"your BOT API key"/sendMessage?chat_id=CHATID2&text="..Msg.."&"
domoticz.openURL(nmaURL)
end
end,
From a dzvents script I can then call the function this way
domoticz.helpers.telegram(domoticz, msg, 'NAME1')
If you only need to send to 1 chat-ID you don't need the IFs of course and put it directly in the url in your helper. In my case I have 2 possible destinations and the possibility to send to both at the same time.
Been using this ever since NotifyMyAndroid stopped their services.
Hope this helps you.