Logic Machine Forum
Send notifications via pushover - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Send notifications via pushover (/showthread.php?tid=734)



Send notifications via pushover - Shalltear - 12.04.2017

Hi, I'm working this example
http://openrb.com/send-instant-messages-to-ios-and-android-devices-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.


RE: Send notifications via pushover - Erwin van der Zwart - 12.04.2017

Hi,

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

BR,

Erwin


RE: Send notifications via pushover - Rodriguez - 17.04.2017

Hi , I have the application on the cell phone, or do I need to work on the desktop version?


RE: Send notifications via pushover - Erwin van der Zwart - 17.04.2017

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


RE: Send notifications via pushover - Rodriguez - 17.04.2017

It works, thank you for your help. Big Grin


RE: Send notifications via pushover - Keitz - 30.01.2018

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--


RE: Send notifications via pushover - Daniel - 31.01.2018

Hi
Why do you bother with this, use our notifications see this thread
https://forum.logicmachine.net/showthread.php?tid=1083&highlight=notifications
BR


RE: Send notifications via pushover - bmodeco - 31.01.2018

Daniel.Hi
[quote pid='7142' dateline='1517397272']
Why do you bother with this, use our notifications see this thread
https://forum.logicmachine.net/showthread.php?tid=1083&highlight=notifications
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


RE: Send notifications via pushover - admin - 01.02.2018

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))



RE: Send notifications via pushover - bmodeco - 01.02.2018

(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.


RE: Send notifications via pushover - Keitz - 01.02.2018

(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)


RE: Send notifications via pushover - Keitz - 02.02.2018

It works fine thank you. Now I can send an image from my camera to pushover message.