How can I get around this?
my script:
Code: Select all
return {
active = true,
on = {
devices = {
'PIR*',
}
},
execute = function(domoticz, device)
local meddelande = 'Inbrotts larmet har utlösts! Anledningen är:'
if (device.state == 'On') then
domoticz.helpers.sendClickatell(domoticz, meddelande, 'Pierre')
domoticz.log(meddelande, domoticz.LOG_ERROR)
end
end
}Code: Select all
local phoneNumbers = {
['PersonA'] = '+31xxxxx',
['PersonB'] = '+31yyyyy'
}
local function smsEncode(str)
-- Convert to GSM 03.38 character set and URL-encode
local utf8Chars={"%%","\n"," ",'"',"&",",","%.","/",":",";","<","=",">","?","¡","£","#","¥","§","Ä","Å","à","ä","å","Æ","Ç","É","è","é","ì","Ñ","ñ","ò","ö","Ø","Ö","Ü","ù","ü","ß", "\\", "*", "'", "%(", "%)", "@", "%+", "%$", "%[", "%]", "%^", "{", "|", "}", "~"}
local gsmChars={"%%25","%%0D","%%20","%%22","%%26","%%2C","%%2E","%%2F","%%3A","%%3B","%%3C","%%3D","%%3E","%%3F","%%A1","%%A3","%%A4","%%A5","%%A7","%%C4","%%C5","%%E0","%%E4","%%E5","%%C6","%%C7","%%C9","%%E8","%%E9","%%EC","%%D1","%%F1","%%F2","%%F6","%%D8","%%D6","%%DC","%%F9","%%FC","%%DF","%%5C","%%2A","%%27","%%28","%%29","%%40","%%2B","%%24","%%5B","%%5D","%%5E","%%7B","%%7C","%%7D","%%7E"}
for i = 1, #utf8Chars, 1 do
str = string.gsub(str, utf8Chars, gsmChars)
end
return str
end
return {
helpers = {
sendClickatell = function(domoticz, message, user, phoneNumber)
local APIId = "<your clickatell API code"
local encMsg = smsEncode(message)
local number = phoneNumber -- optional
if (phoneNumber == nil) then
-- get it from the list above
number = phoneNumbers[user]
end
local url = "https://platform.clickatell.com/message ... nd?apiKey=" ..
APIId ..
"&to=" ..
number ..
"&content=" ..
encMsg
domoticz.openURL(url)
end
}
}