Pushover Notification with Image file


There was a topic which was closed last year.

So I decided to start a new one to ask and to try to understand.

If I got it right, code is supposed to send Hubitat push notification with image. That is exactly what I'm missing. At the moment I'm sending a photo to phone as an email when doorbell is pushed. Photos is taken from one of the cameras in blue iris server.
It would be much better if image would show up as push notification from Hubitat rather than email.

Here's the thing though. I do not understand how can I use this code snippet and where do I need to use it? There was a message in older topic which said that "this code should be used as a part of bigger app/driver. What does that mean..

def imageData

log.debug "Getting Notification Image"

//Get Notification Image
  uri: "[Notification Image URL]",
contentType: "*/*",
//Add HTTP Auth Header (If required)
headers: ["authorization": "Basic [Base64 Encoded Credentials]" ],
textParser: false])
{ response ->
  imageData = response.data
  log.debug "Notification Image Received (${imageData.available()})"

def bSize = imageData.available()
byte[] imageArr = new byte[bSize]
imageData.read(imageArr, 0, bSize)

//Pushover API Credentials
def apiUser="[Pushover API User]"
def apiToken="[Pushover API Token]"

//Top Part of the POST request Body
def postBodyTop = """----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="user"\r\n\r\n${user}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="token"\r\n\r\n${token}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="title"\r\n\r\n${title}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="message"\r\n\r\n${message}${(url?" "+url:"")}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="device"\r\n\r\n${device}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="sound"\r\n\r\n${sound}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="priority"\r\n\r\n${priority}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="retry"\r\n\r\n${retry}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="expire"\r\n\r\n${expire}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="timestamp"\r\n\r\n${timestamp}\r\n----rjtvk266t3df6jkpb4\r\n
Content-Disposition: form-data; name="attachment"; filename="image.jpg"\r\nContent-Type: image/jpeg\r\n\r\n"""

//Bottom Part of the POST request Body
def postBodyBottom = """\r\n----rjtvk266t3df6jkpb4--"""

byte[] postBodyTopArr = postBodyTop.getBytes("UTF-8")
byte[] postBodyBottomArr = postBodyBottom.getBytes("UTF-8")

//Combine different parts of the POST request body
ByteArrayOutputStream postBodyOutputStream = new ByteArrayOutputStream();


byte[] postBody = postBodyOutputStream.toByteArray();

//Build HTTP Request Parameters
def params = [
	requestContentType: "application/octet-stream",
	headers: ["content-type": "multipart/form-data; boundary=--rjtvk266t3df6jkpb4"],
	uri: "https://api.pushover.net/1/messages.json",
	body: postBody

log.debug "Sending Notification Request"
httpPost(params){response ->
	if(response.status != 200) {
		log.error "HTTP Request error ${response.status}."

log.debug "Notification Request Complete"

is there anyone who is interested of helping me with this one?
I'm tagging @gavincampbell and @markbellkosel84 from the old post if you want to participate. :shushing_face:

You can do this directly from within BlueIris.

Use a Web Request alert action.
Request Type: https://
URL: api.pushover.net/1/messages.json
Post/payload: {"token":{your Pushover token},"user":{your Pushover user},"message":"Motion detected on camera: &CAM","title":"Blue Iris Alert","attachment_type":"image/jpeg","attachment_base64":"&ALERT_JPEG"}
Add HTTP headers: Content-Type:application/json

I think I had to request that Pushover add JSON support to my account. I think it was a simple email to Pushover support for this.

Once I figured this out, it removed my dependency on BlueIris needing to send emails, or use Pushover to send emails. Saved lots of space in my GMail account I was using to send/receive alerts.

1 Like

Thanks, just what I needed.
More stuff to figure out... :wink:

Well this was a good one! I'm going to try this but first things first. How do I trigger web request when doorbell (paired to hubitat) is pressed. At the moment :

  • doorbell gets pressed
  • webcore piston sends GET to blue iris to take a snapshot
  • eventghost on blue iris server runs vbs file which grabs the snapshot and sends it via email

Now if I'm able to run the web request from Blue iris, how can I command blue iris to run that web request when doorbell button is pressed.

Not sure. That sounds overly complicated. I have BI send alerts via Pushover for any person at the front door. Regardless whether they ring the doorbell.

You may want to research the BI help files, HTTP Interface section. There are a lot of HTTP interface commands available in BI.

Maybe trigger that camera to trigger and alert.

Actually I found the solution already and it is (like you said) send trigger command to blue iris. I'm not using "alert" tab at all. I'm using Trigger->Immediate actions and there I'm using your web request template. I did not yet succeed to get notification to my phone but that's probably because of:

I need to send email to support.

I looked back at my email exchange with Pushover. Seems they more specifically added attachment support to the JSON exchange on my account.

Here was their response:

"I've added support for an attachment_base64 parameter that you can
send, along with the attachment_type parameter that should be set to
the attachment's MIME type ("image/jpeg", "image/png", etc.).

You can send attachment_base64 as a normal parameter, either doing
URL-encoded POST data or in the JSON body with Content-Type set to

Remove your attachment parameters for now, just to troubleshoot getting your JSON to work. I think I used POSTMAN when I was troubleshooting the JSON request, just to simplify my testing and remove all Hubitat/BI variables from the aspect.

1 Like

Yeah..me and my language barrier in english.. I got an answer from support already and they were like "what are you talking about". I kindly copied the response you earlier got from them and I hope it clarifies my need. :slight_smile:

About the troubleshooting while waiting answer from support.
I did try to send just a bulk pushover notification from Blue Iris to my phone and that did not succeed. I'm not sure (I do not understand) am I capable of testing pushover from BI just by leaving attachment part away from Post/payload section like this:
{"token":{your Pushover token},"user":{your Pushover user},"message":"Motion detected on camera: &CAM","title":"Blue Iris Alert"}
..or am I going too straight forward..

I did read your message and you are pointing to do the tests without Hubitat/BI variables but thought simply pushover from BI should work.

I just found a slightly different way of doing this and it works straight without dealing with pushover support.

curl https://api.pushover.net/1/messages.json -s --form-string "token=XXXXXXXXXXXXXXXX" --form-string "user=YYYYYYYYYYYYYYYYY" --form-string "message=&CAM &MEMO Hi-Res UI3" --form-string "html=1" --form-string "device=YOUR_PUSHOVER_DEVICE_NAME(S)_HERE" --form-string "sound=YOUR_PUSHOVER_SOUND_HERE" -F "attachment=@C:\BlueIris\Alerts&ALERT_PATH"

Just need to replace XXXXX and YYYYY and attachment path to right ones per user. I also need to do small adjustments by following this:

This is how it looks on blue iris side:

And in a webcore piston it's like this: