Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Global Telegram settings
- telegramAPI = ""
- telegramChatID = ""
- telegramGroupID = ""
- -- Set weahter alarm colors
- weatherAlarmColorsData = {
- ["1"] = "groen",
- ["2"] = "geel",
- ["3"] = "oranje",
- ["4"] = "rood"
- }
- weatherAlarmWarningsData = {
- ["Wind"] = "Wind",
- ["Snow/Ice"] = "Sneeuw/ijs",
- ["ThunderStorm"] = "Onweer",
- ["Fog"] = "Mist",
- ["High Temp"] = "Hoge temperaturen",
- ["Low Temp"] = "Lage temperaturen",
- ["Coastal Event"] = "Kustgebeurtenis",
- ["Forestfire"] = "Bos/weide brand",
- ["Avalanches"] = "Lawines",
- ["Rain"] = "Regen",
- ["Flood"] = "Overstromingen",
- ["Rain-Flood"] = "Regen overstromingen"
- }
- -- Global's
- json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
- json.strictTypes = true
- -- Prepare raw data to json
- weatherAlarmColors = json:encode(weatherAlarmColorsData)
- weatherAlarmWarnings = json:encode(weatherAlarmWarningsData)
- function sendTelegram(Message, Channel)
- if(Channel == "private") then
- chatID = telegramChatID
- else
- chatID = telegramGroupID
- end
- local prep = assert(io.popen('curl -s -X POST https://api.telegram.org/bot'..telegramAPI..'/sendMessage -d chat_id='..chatID..' -d parse_mode=Markdown -d text="'.. Message ..'"'))
- local data = prep:read('*a')
- prep:close()
- local jsonData = json:decode(data)
- if(jsonData['ok'] == false) then
- print("Telegram kon niet verstuurd worden!: "..jsonData['error_code'].." "..jsonData['description'])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement