Attach photo in notification

Sorry, I can’t add anything to that.

Hi guys.
I’m using pushbullet to push an image from my camera at the door when someone rings the bell. :slight_smile:

I used this python library:

My python script:

from pushbullet import Pushbullet
import urllib.request, os, time

pb = Pushbullet(“pushbullet API key”)
urllib.request.urlretrieve (“http://x.x.x.x/image/jpeg.cgi”, “/local dir/picture.jpg”)
with open(“/local dir/picture.jpg”, “rb”) as pic:
file_data = pb.upload_file(pic, “ringerpaa.jpg”)
push = pb.push_file(**file_data)

Add your own pushbullet API key and the ip to your camera.
It will get the picture from the camera and store it localy in the folder spcified.

I start this python script from a script.

4 Likes

Ok. I’m progressing with my problem with pushbullet. I know that the problem is not with my account but with the curl version on Linux. I tried from two different ubuntu distribution and I have the same problem. I also tried with curl on the Raspberry (weezy) and I got the same.
But when installed and tried curl on windows the upload is working fine! That’s very strange… I don’t know what could be the root cause on Linux. It seems that all the scripts around (perl, php, phyton, bash) are based on curl or curl library.

I will keep trying…

I’m becoming crazy… The same command works on windows but not in Linux. (any linux)

I am using Ubuntu 14.04.02 LTS (64bit) with no issues. That’s weird.

Hello,

Problem solved!!!
After doing a lot of tests I discovered that the problem was on the router. For some reason the server is trying to stablish a connection to the client or something like this. That’s very strange for a POST but I noticed that If I set the DMZ to the client’s IP then everything is working.
I still don’t know why this is working on windows… And why it is working with very small files… But it is working now :slight_smile: !!!
I discovered this when I run the Linux on a Window’s virtual machine. Then it was working… because it was using the Windows NW adaptor.

Anyway, it is working now.

Thanks,

1 Like

So is this working using @rpr script or something else? Cause I’d like to try this myself.

Yes. I’m using that version written in Perl. It is working fine and it is easy to understand.
I modified the code a little bit in order to push the message to all my devices (instead of one) and also to change the Subject of the message (instead the name of the file).

There are more versions available in bash, python and php with more functionalities but this one is doing the job pretty well.

Regards,
Alfredo.

Yeah, after I found that Perl script I found a python library that does it all, much easier. Meh, same result for me. Glad you got it working!

why not just use motion; and scp the latest image by time stamp. I can do it in a one-liner in bash.

I wonder if you can do the same with NMA? I am already setup for them.

Could you elaborate on this a bit, please?

I was wondering if you can do the same thing using NMA.

No, I meant about the bash script method.

Where would you scp the image to, exactly?

For the last year I’ve been sending a trigger to a mac that grabs 20 consecutive images from an ipcamera and then used imagemagik to create and animated gif and iMessage it to me. I’ll have to test gif’s with pushbullet and ideally pushover.

Thanks for the scripts.

Pushbullet can’t reproduce an animated gif. I think that it only display the first frame in the phone. The GIF is only animated on Pushbullet for chrome.

I am pretty sure you could do this easily with NMA.

I’m going to try to adapt all the discussion here and instead of pushbullet I’ll use Gmail Email notification https://home-assistant.io/components/notify.smtp/

Just need to configure the scripts so they place the snapshots into the correct folder for code below:

burglar: 
    alias: Burglar Alarm
    sequence:
      - service: shell_command.snapshot
      - delay:
            seconds: 1
      - service: notify.NOTIFIER_NAME
        data:
            title: 'Intruder alert'
            message: 'Intruder alert at apartment!!'
            data:
                images: 
                    - /home/pi/snapshot1.jpg
                    - /home/pi/snapshot2.jpg

First of all thank you all for the scripts shared here. Helped me out alot with my doorbell image notification!

Second I am wondering if the images is stored in pushbullet? Will I eventually run out of storage room there? I am using the Perl script you posted.

Yes, The image file is stored in pushbullet. I think that it will be available in that location during some time and not forever.
Like in whatsapp that after some time the files are not longer available to be downloaded.

2 Likes