Video in iOS Notifications

First post - so please forgive me in advance!

I’ve been playing around with Homeassistant for a while now and its all working well. I’ve added in a few automations, and this is where my problem lies!

I am trying to take a 20sec video stream from one of my cameras when my garage door opens and send it as an attachment in an iOS notification. My current config works, but only sometimes.

automation:
    hide_entity: True
    trigger:
      platform: state
      entity_id: binary_sensor.door_window_sensor_158d0001de8b2e
      from: 'off'
      to: 'on'

    action:
      - service: shell_command.take_video
      - delay: 0:01
      - service: notify.ios_iFone
        data:
          message: "Garage Door Opening!"
          data:
            attachment:
              url: 'https://<MYIP>.duckdns.org/local/capture.mp4'
              hide-thumbnail: false

My shell command to take the video is as follows:

shell_command:
  take_video: 'ffmpeg -y -i rtsp://10.1.1.110/unicast -r 30  -vcodec copy -an -t 20 "/home/homeassistant/.homeassistant/www/capture.mp4"'

Any ideas as to why it sometimes works and sometimes doesn’t?

I’m running Homeassistant 0.73 and iOS11.4.
Thanks

2 Likes

Assuming the notification always show up on your iphone, just sometimes without the mp4.
Are you sure the captured mp4 file is ready for notification?
Depending on your system and live stream, ffmpeg capture may take couple of seconds to finish creating/updating mp4 file. Also, not sure how the system behaves if the mp4 file is being written to when HA tries to send the notification.
Maybe try testing with already created mp4 file to see if the problem is from the mp4 creation and/or timing of creation.

Hope that helps.

1 Like

Thanks - I do have a delay of 1 min between taking the video and sending the notification, but I might need to make this longer!

In case anyone is interested, it turns out my wireless camera feed was recording in 1280x1024 which wasn’t working so altered my recording script to resize to 320x240 and it worked!

Working shell command below:

take_downsize_video: 'ffmpeg -y -i rtsp://10.1.1.110/unicast -r 30 -vcodec copy -an -s 320x240 -t 20 "/home/homeassistant/.homeassistant/www/capture.mp4"'

in case anyone is still interested, it seems that as long as the ratio is 320x240, it works. So 1920x1440 also works.

I’m having the same issue. 320x240 and 640x480 work for me but nothing larger. It’s frustrating because the apple documentation doesn’t list any limitations of the UNNotificationAttachment class other than a 50MB file size. I wonder if the limitation is in the app itself rather than an iOS issue. Do you happen to have a 1920x1440 video file that you know works? I’m curious to do more testing.

im, after a long time this issue been not discussed, still struggeling with this - i have a notification that should show a video recorded locally - sometimes everything works fine but on other days there is just this spinning wheel. We are about a hug step ahead of the old config for ios notification, but things doesnt changed for me - still no video arriving here.
will try the resolution fix mentioned here, but could this also be due to internet speed restrictions? video is about 800kb so its likely not that important…

just to complete my function node :

hassio 2022.2.1 companion 2022.2 i think=)

var message = msg.payload.event.file
var final_msg =  `/media/outside_video/${message}` 

var payload = {
    "data":{
        "message": "",
        "title": "📽 Tür",
        "data": {
            "video": `${final_msg}`,
            "group": "motion_outside",
        },
},
}

msg.payload = payload
return msg;

Instead of the delay you could also use the folder watcher integration and wait for the file closed event.

For a solution look here: How does my automation know when a camera.record service on a stream is complete? - #14 by bt04