Pushing Images with Pushover 3.0

Either the component doesn’t support templated file names, or the time changed by one or more seconds and the second one evaluated to a different file name.

I already tried to remove seconds from the filename, so it must be something else. Not supporting templated file names could be it indeed.

Make sure you use data_template and not just data. Also, either wrap the value in quotes or use >- like this:

- service: notify.pushover_test
  data_template:
    message:  "Snapshot"
    title: "Snapshot"
    data:
      attachment: >-
        /share/yi_snapshot_{{now().strftime('%Y%m%d-%H%M%S')}}.jpg
3 Likes

Thanks Steven, data_template works.

1 Like

Someone knows about sending gif with pushover?

According to the API documentation for pushover,

Each message may only include one attachment, and attachments are currently limited to 2,621,440 bytes (2.5 megabytes). Attempting to send attachments larger than this size will be rejected with an API error (or server error for extremely large file attempts). Any resizing of images to fit under this limit must be done on the sending side before making the API request.

It appears that their client application knows how to render GIF images, or animated GIF images if that was what you were intending, according to this blog post.

Gif attachments with pushover have also been on my to do list, but haven’t gotten around to tinkering with that.

I do have these 2 resources for you:

I can safely say that I did test sending an animated gif with pushover and it works fine. The part that I never got around to testing is generating the actual gif from the camera. (I just used a generic gif I had laying around).

Yesterday I was reading I saw that people said that it was now possible, so I was asking if someone around here had done it

Thank you for answering also, yesterday I read that documentation but I still haven’t had time to prove anything, my cameras are reolink and I was wondering if the shell command to generate the gif would be valid the same or only it would be valid for the unifi cameras

Yes, the shell command should work for any camera.
What you can maybe do is use the stream component to record an mp4 with the camera.record service.
Save that mp4 somewhere, then use a shell_command and ffmpeg to convert it to a gif and then use pushover to send the gif, but like I said I haven’t really played around with this that much, but that’s how I would approach it. Good luck.

I do think the recording to mp4 then converting to gif process will take a couple of seconds (depending on your platform), so put a few seconds delay in your notification automation otherwise the notification might be empty.

I have tried but I have not succeeded, someone here have a shell_command working with rtsp camera? , I should tell I’m on hass.io too

I have managed to advance something, but I have two problems:
the first one, although I’m recording a 15-second video, just creates a 2-second gif
the second, before with the snapshot service I was overwriting the file, and so the image I sent was always new, now with the gif always sends me the old file
i have this:

shell_command:
  prueba: ffmpeg -ss 15 -t 10 -i /config/www/snapshot/entrada.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 /config/www/snapshot/entrada.gif
- id: 'prueba'
  alias: prueba
  trigger:
  - entity_id: binary_sensor.camara_entrada
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: camera.entrada
      filename: /config/www/snapshot/entrada.mp4
      duration: 15
    service: camera.record
  - delay: 00:00:20
  - service: shell_command.prueba
  - delay: 00:00:10  
  - data:
      data:
        attachment: /config/www/snapshot/entrada.gif
        html: "1"
      title: MOVIMIENTO DETECTADO
      message: Se ha detectado movimiento en la entrada.
    service: notify.pushover

I hope someone can enlighten me, thank you

Have you tried increasing the delay? I did something like this a while back and found the creating the gif was actually longer than I expected. So maybe the 10 second delay after the shell_command is not enough?

It could be that the 20 second delay for taking the video might not be long enough; you ought to check the captured .mp4 file to see if its complete. And it seems likely that the shell command is running asynchronously as well.

A variation of this question has come up before in How does my automation know when a camera.record service on a stream is complete? and I suppose there’s the more general question of how you synchronized with these external processes that get kicked off.

fixed, it was the delay after create the video I have also solved the second problem with another script, I am very new in this and surely it can be improved, but I leave here my small contribution in case anyone is interested:

- id: 'Foto Movimiento Entrada'
  alias: Foto Movimiento Entrada
  trigger:
  - entity_id: binary_sensor.camara_entrada
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: camera.entrada
      filename: /config/www/snapshot/entrada.mp4
      duration: 15
    service: camera.record
  - delay: 00:00:30
  - service: shell_command.camara_entrada
  - delay: 00:00:05
  - data:
      data:
        attachment: /config/www/snapshot/entrada.gif
        html: "1"
      title: MOVIMIENTO DETECTADO
      message: Se ha detectado movimiento en la entrada.
    service: notify.pushover
  - service: shell_command.borrado_gif_entrada 

shell_command:

  camara_entrada: ffmpeg -i /config/www/snapshot/entrada.mp4 -b 2048k /config/www/snapshot/entrada.gif
  borrado_gif_entrada: rm -f /config/www/snapshot/entrada.gif

thanks to ptdalen and Imamakos to help me

2 Likes

I’m happy someone was able to get a PR through for this, but it looks like my original authentication code was dropped. In case you need it, I’ve synced my old custom component code with the new release here:

Here’s a sample config snippet:

      data:
        message: 'SECURITY ALERT: Motion was detected at the Front Door'
        attachment: !secret cam_front_door_latest_url
        auth: basic
        username: !secret cam_front_door_username
        password: !secret cam_front_door_password

I’ll work on getting another PR submitted to allow authenticated url requests.

hi, i am new to this, want to give it a try, since html5 messages are not working instantly
so whats up with the priority ? for instant messages , whats better? priority 0 or 1 or -1 ?

I always set it in “1”, I’m not sure about whats better, but I’m happy with how works

See the API reference on pushover.net - https://pushover.net/api#priority

The priority is related to the notification actions on the client devices when the message is received. The zero priority essentially respects the preferences on the client (quiet hours, etc.) while higher and lower preferences either override the muting of notifications, or inhibit notifications. (And by “notifications” I mean beeps, vibration, notification light on the device, not the actual message itself.)

Ok, all clear now :wink: