This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Send notifications via pushover
#1
Brick 
Hi, I'm working this example
http://openrb.com/send-instant-messages-...s-with-lm/
but I have a question about this.

Regarding this part of the code:
Require 'ssl.https'
Local pushover_url = 'https://api.pushover.net/1/messages.json'

In this line, "pushover_url" this direction from where was taken?
Well I already have the account in pushover, and I got the key and the token but it still does not let me send messages from the script.
Thank you.
Reply
#2
Hi,

Did you set default gateway and DNS in your network adapter settings?

BR,

Erwin
Reply
#3
Hi , I have the application on the cell phone, or do I need to work on the desktop version?
Reply
#4
Hi,

You need to create a application on the website of pushover and put the generated application token in the script and you can use the phone app, in the app you see your user token, this one must also be put in the script.

After both keys are filled in you should be able to receive push messages on your phone.

BR,

Erwin
Reply
#5
It works, thank you for your help. Big Grin
Reply
#6
I will send a jpeg file attachments with pushover. But I do not know how.
Can anybody help me ?

i have tried this : 
local data_str = 'token=****************&user=*******************&device=gsm&message=snapshot.jpeg&attachment=' .. image .. '&title=LogicMachine&sound=bike&priority=0'

local res, code, headers, status = ssl.https.request(pushover_url, data_str)
 
I receive a message with an icon of a image but no my image is not there.

this is info from pushover :
other HTTP headers]

Content-Type: multipart/form-data; boundary=--abcdefg



----abcdefg

Content-Disposition: form-data; name="user"



[ your Pushover user key ]

----abcdefg

Content-Disposition: form-data; name="token"



[ your Pushover API token ]

----abcdefg

Content-Disposition: form-data; name="message"



your message here

----abcdefg

Content-Disposition: form-data; name="attachment"; filename="your_image.jpg"

Content-Type: image/jpeg



[ raw binary data of image file here ]
----abcdefg--
Reply
#7
Hi
Why do you bother with this, use our notifications see this thread
https://forum.logicmachine.net/showthrea...ifications
BR
------------------------------
Ctrl+F5
Reply
#8
Daniel.Hi
[quote pid='7142' dateline='1517397272']
Why do you bother with this, use our notifications see this thread
https://forum.logicmachine.net/showthrea...ifications
BR
[/quote]

Hi Daniel,
I have been using pushover for several months now and am sending more than 10.000 messages a month using the LM5 in my KNX-system. Since the number of messages is too (limit of 7.500)  high I use different pushover-applications to separate the messages (weather, heating, alarmsystem, ventilation, etc...). It also allows formatting in the messages (I included a screendump from my ipad). Apart from that it also allows for priority-messaging: most of my message are just logging (low priority), you can elevate priority level so a pop-up box shows f.e. when an alarm is triggered.
I did not know that it also allows for sending of attachments - apparently since mid january... This was for me the only thing still missing since I want to send pics taken by my security cams.
So I do think that the pushover platform still has some advantages...maybe some good ideas for your next version...
Keep up the good work, still loving my LM.
Thanks, Bart
   

(30.01.2018, 18:02)Keitz Wrote: I will send a jpeg file attachments with pushover. But I do not know how.
Can anybody help me ?

i have tried this : 
local data_str = 'token=****************&user=*******************&device=gsm&message=snapshot.jpeg&attachment=' .. image .. '&title=LogicMachine&sound=bike&priority=0'

local res, code, headers, status = ssl.https.request(pushover_url, data_str)
 
I receive a message with an icon of a image but no my image is not there.

this is info from pushover :
other HTTP headers]

Content-Type: multipart/form-data; boundary=--abcdefg



----abcdefg

Content-Disposition: form-data; name="user"



[ your Pushover user key ]

----abcdefg

Content-Disposition: form-data; name="token"



[ your Pushover API token ]

----abcdefg

Content-Disposition: form-data; name="message"



your message here

----abcdefg

Content-Disposition: form-data; name="attachment"; filename="your_image.jpg"

Content-Type: image/jpeg



[ raw binary data of image file here ]
----abcdefg--

Hi Keitz,
I am very much interested in this feature also...
This is the link with some more info: https://pushover.net/api#attachments
Apparently it needs some sub-headers to identify what type of image.
Don't know on how to implement it in the existing code.
Maybe admin, Daniel or Erwin can have a look...
Thanks, Bart
Reply
#9
Try this, I've tested it with nginx and apache so other servers might reject this request. Fill params table with your post arguments, filedata variable should contain binary data of your jpeg image, set request url as needed.

Code:
require('ssl.https')

boundary = os.date('%d%m%Y%H%M%S')

params = {
  {
    name = 'token',
    value = '12345',
  },
  {
    name = 'user',
    value = 'testuser',
  },
  {
    name = 'attachment',
    filename = 'snapshot.jpg',
    ctype = 'image/jpeg',
    value = filedata,
  }
}

body = { '--' .. boundary }

for _, param in ipairs(params) do
  line = string.format('Content-Disposition: form-data; name=%q', param.name)
  if param.filename then
    line = string.format('%s; filename=%q', line, param.filename)
  end
  body[ #body + 1 ] = line

  if param.ctype then
    body[ #body + 1 ] = string.format('Content-Type: %s', param.ctype)
  end

  body[ #body + 1 ] = ''
  body[ #body + 1 ] = param.value
  body[ #body + 1 ] = '--' .. boundary
end

-- last boundary
body[ #body ] = body[ #body ] .. '--'
-- empty line at the end
body[ #body + 1 ] = ''

bodydata = table.concat(body, '\r\n')

resp = {}

log(
  ssl.https.request({
    url = 'https://...',
    sink = ltn12.sink.table(resp),
    method = 'POST',
    source = ltn12.source.string(bodydata),
    headers = {
      ['content-length'] = #bodydata,
      ['content-type'] = 'multipart/form-data; boundary=' .. boundary
    }
  })
)

log(table.concat(resp))
Reply
#10
(01.02.2018, 13:09)admin Wrote: Try this, I've tested it with nginx and apache so other servers might reject this request. Fill params table with your post arguments, filedata variable should contain binary data of your jpeg image, set request url as needed.

Code:
require('ssl.https')

boundary = os.date('%d%m%Y%H%M%S')

params = {
 {
   name = 'token',
   value = '12345',
 },
 {
   name = 'user',
   value = 'testuser',
 },
 {
   name = 'attachment',
   filename = 'snapshot.jpg',
   ctype = 'image/jpeg',
   value = filedata,
 }
}

body = { '--' .. boundary }

for _, param in ipairs(params) do
 line = string.format('Content-Disposition: form-data; name=%q', param.name)
 if param.filename then
   line = string.format('%s; filename=%q', line, param.filename)
 end
 body[ #body + 1 ] = line

 if param.ctype then
   body[ #body + 1 ] = string.format('Content-Type: %s', param.ctype)
 end

 body[ #body + 1 ] = ''
 body[ #body + 1 ] = param.value
 body[ #body + 1 ] = '--' .. boundary
end

-- last boundary
body[ #body ] = body[ #body ] .. '--'
-- empty line at the end
body[ #body + 1 ] = ''

bodydata = table.concat(body, '\r\n')

resp = {}

log(
 ssl.https.request({
   url = 'https://...',
   sink = ltn12.sink.table(resp),
   method = 'POST',
   source = ltn12.source.string(bodydata),
   headers = {
     ['content-length'] = #bodydata,
     ['content-type'] = 'multipart/form-data; boundary=' .. boundary
   }
 })
)

log(table.concat(resp))

Thanks admin for the fast response! Will try it out.
Reply
#11
(01.02.2018, 15:37)bmodeco Wrote:
(01.02.2018, 13:09)admin Wrote: Try this, I've tested it with nginx and apache so other servers might reject this request. Fill params table with your post arguments, filedata variable should contain binary data of your jpeg image, set request url as needed.

Code:
require('ssl.https')

boundary = os.date('%d%m%Y%H%M%S')

params = {
 {
   name = 'token',
   value = '12345',
 },
 {
   name = 'user',
   value = 'testuser',
 },
 {
   name = 'attachment',
   filename = 'snapshot.jpg',
   ctype = 'image/jpeg',
   value = filedata,
 }
}

body = { '--' .. boundary }

for _, param in ipairs(params) do
 line = string.format('Content-Disposition: form-data; name=%q', param.name)
 if param.filename then
   line = string.format('%s; filename=%q', line, param.filename)
 end
 body[ #body + 1 ] = line

 if param.ctype then
   body[ #body + 1 ] = string.format('Content-Type: %s', param.ctype)
 end

 body[ #body + 1 ] = ''
 body[ #body + 1 ] = param.value
 body[ #body + 1 ] = '--' .. boundary
end

-- last boundary
body[ #body ] = body[ #body ] .. '--'
-- empty line at the end
body[ #body + 1 ] = ''

bodydata = table.concat(body, '\r\n')

resp = {}

log(
 ssl.https.request({
   url = 'https://...',
   sink = ltn12.sink.table(resp),
   method = 'POST',
   source = ltn12.source.string(bodydata),
   headers = {
     ['content-length'] = #bodydata,
     ['content-type'] = 'multipart/form-data; boundary=' .. boundary
   }
 })
)

log(table.concat(resp))

Thanks admin for the fast response! Will try it out.
Thanks I will try it.
local data_str = 'token=token&user=user&device=gsm&message=test&attachment='??????'&title=LogicMachine&sound=bike&priority=0'

local res, code, headers, status = ssl.https.request(pushover_url, data_str)
Reply
#12
It works fine thank you. Now I can send an image from my camera to pushover message.
Reply


Forum Jump: