Pushing Images with Pushover 3.0

Latest API version for Pushover allows to attach images, how can we get this new feature onboard? More info https://updates.pushover.net/post/170043375237/pushing-images-with-pushover-30

@xtianpaiva you hear any updates on this? Iā€™d love to be able to use this in my setup for push image notification on my front doorbell.

Hi, same project here, still waiting, maybe we can have news with the next HA update.

Any more news about this feature? Would like to use it for my doorbell.

Is anyone else already working on this? If not, I figured Iā€™d give it a shot.

1 Like

I have this working locally and have tested it by attaching an image like ā€˜/local/xyz.pngā€™ (www directory) as well as from a security camera with basic auth. Iā€™m working through cleaning it up and testing the edge cases but will get this submitted as soon as I can.

2 Likes

I would be very interested in this as well, would you like to share the code?

I just submitted a pull request for this (#13748), but you can find my updated code here if youā€™d like to test it locally: https://github.com/brkr19/home-assistant/blob/dev/homeassistant/components/notify/pushover.py

Edited to fix the repository in the url

1 Like

Great job! What platform do you use? Iā€™m running HA on docker, do you know how I would test it on there?

Iā€™m just learning Docker myself, but I added this to my docker run command to use my local source dir instead: -v /home/brkr19/opt/home-assistant:/usr/src/app (so my local source dir was in ~/opt/home-assistant). Thereā€™s probably a better way, but this was what worked for me while doing frequent code changes and testing.

Great, thanks

Hi, @brkr19 It seems that your pull request is now Live. could you update the documentation how we should use it?
i have tried a few things but i didnā€™t manage to get it working.

{ ā€œmessageā€: ā€œTest pluginā€,
ā€œfilenameā€: { ā€œurlā€:ā€œ5 Vorteile der Mediation fĆ¼r Fahrradfahrer ā€“ GBSun ā€“ Sommer, Sonne, Fahrradā€
} }

{ ā€œmessageā€: ā€œTest pluginā€,
ā€œattachmentā€: { ā€œurlā€:ā€œ5 Vorteile der Mediation fĆ¼r Fahrradfahrer ā€“ GBSun ā€“ Sommer, Sonne, Fahrradā€
} }

Hmm, thatā€™s strange - last I saw, it was rejected due to the desire to continue using the third-party library instead of the APIs directly. I actually had a PR for the documentation too, but then had to roll that back.

Hereā€™s an example in case it is actually live though:

- alias: Garage motion detected
  trigger:
    platform: state
    entity_id: sensor.garage_motion
    from: '0'
    to: '1'
  condition:
    - condition: state
      entity_id: input_boolean.security_armed
      state: 'on'
  action:
    - service: notify.pushover
      data_template:
        message: "Security system: Motion in Garage!"
      data:
        title: "Home Assistant"
        data:
          priority: 1
          sound: siren
          file:
            url: !secret cam_garage_latest_url
            auth: basic
            username: !secret cam_garage_username
            password: !secret cam_garage_password
1 Like

did your code every get rolled in home assistant to support images?

looks like the 3rd party library supports it, Iā€™m no developer though
https://pushover.net/faq#library-python

Alternatively, the 3rd party pushnotify Python package written by Jeffrey Goettsch, the pushover Python 3 package written by Wyatt Johnson, and the Chump Python package written by Karan Lyons are available.

To send an image attachment, the 3rd party Requests library can be used. For example, to send the file ā€œyour_image.jpgā€:

import requests
r = requests.post(ā€œhttps://api.pushover.net/1/messages.jsonā€, data = {
ā€œtokenā€: ā€œAPP_TOKENā€,
ā€œuserā€: ā€œUSER_KEYā€,
ā€œmessageā€: ā€œhello worldā€
},
files = {
ā€œattachmentā€: (ā€œimage.jpgā€, open(ā€œyour_image.jpgā€, ā€œrbā€), ā€œimage/jpegā€)
})
print(r.text)

I just updated my code here: 6f354e6. Iā€™ll be testing it and creating a new PR soon, but in the meantime, feel free to grab this code for now.

2 Likes

How can I modify original pushover.py?

Itā€™s best not to edit the original files. I used the custom_components method described here; https://community.home-assistant.io/t/editing-component-files-in-hassio/24273
So I took the new pushover.py from @brkr19 and placed it in config/custom_components/notify
Works like a charm (reboot ofcourse) really happy, thanks a lot @brkr19

2 Likes

Using this a custom component worked really well. Thanks for the tip

Iā€™m trying to have my camera image sent to Pushover but still, with the custom component, have issues.
Could you share you automation lines so I can compare?
thanks

nobody can help?