Hi Golleman,
maybe there's a problem with the annotations or the hashtags, when they are empty...
I'll do a "normal" notification in this way - Which work's fine:
Code: Select all
if devicechanged['TEST-Schalter'] == 'On' then
commandArray['SendNotification'] = 'Titel#Hello, this is an test message!'
end
If you want to send an message with higher priority just add an #1 or #2 at the end, just before the closing ' .
The format with commandArray-Table which i use without problem's is:
Code: Select all
if devicechanged['TEST-Schalter'] == 'On' then
commandArray[#commandArray+1] = { ['SendNotification'] = 'Titel#Hello, this is an test message!' }
end
And if you wan't to use a function, for example to send the message only at one of your devices, this is an possibility (found the base for this here in the forum):
Code: Select all
function Pushmessage(priority, title, message, device, sound)
-- priority = -2,-1,0,1,2
-- title = title of the message
-- message = message you'll like to send
-- device = The device which should receive the message. For example: All, Name1, Name2
if device == 'All' or device == nil then device = ''
elseif device == 'Name1' then device = 'Name-of-the-device1-at-the-Pushover-Account'
elseif device == 'Name2' then device = 'Name-of-the-device2-at-the-Pushover-Account'
end
-- sound = The sound you would like to hear; Find here: https://pushover.net/api#sounds
if sound == nil then sound = '' end
-- Pushover-Account:
UserKey = '1234-find-in-Pushover'
ApiToken = '1234-find-in-Pushover'
-- Send the message:
os.execute('curl --data "token='..ApiToken..'&user='..UserKey..'&title='..encodeURI(title)..'&message='..encodeURI(message)..'&priority='..tostring(priority)..'&sound='..sound..'&device='..device..'" https://api.pushover.net/1/messages.json')
print('Send an push-message to: '..device)
end
In the pushover-function i use another function for encode the message as an uri, to prevent problems with special characters:
Code: Select all
function encodeURI(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
With the function sending a message is done as follows:
Code: Select all
if devicechanged['TEST-Schalter'] == 'On' then
Pushmessage('0', 'Title', 'Hello, this is an test message!', 'All')
end
--