Cant get image to send in ios notication - help :)

Hi

I am trying to send an image from from the camera when an automation is sent

The trigger works as i get the notification, but no image

where is the confg

  • alias: 'Notify Doorbell Pressed'
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: binary_sensor.doorbell
      from: 'off'
      to: 'on'
    action:
      service: notify.ios_iphonename
      data:
        message: 'Some has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}}'
    data:
      push:
        category: camera
      entity_id: camera.front_door_camera
    

can anyone help ?

You also need the attachment part. See my repo for couple of examples.

Yeah, @arsaboo is right, I just updated the docs on this the other day: https://home-assistant.io/docs/ecosystem/ios/notifications/content_extensions/

I also made it so that it won’t be necessary in the next version of the iOS app.

is there way to send a static image at the point and time of the automation, as these sends a stream, and i might miss who has pressed the door bell if looked a few mins after :slight_smile:

That will be easier to do in the next version of Home Assistant coming this weekend with the snapshot feature: https://github.com/home-assistant/home-assistant/pull/10207

I would suggest waiting for that rather than coming up with a solution before then.

Great Thanks, look forward in trying it out :slight_smile:

Does anyone know how to use the snapshot feature, im confused lol

See this for how to get snapshot service to work. You can then use the image in notifications.

Hi I can get the service to work manually but I am confused how I build an automation out of it ??

Snapshot Service

{“entity_id”:“camera.front_door_camera”, “filename”:"/home/homeassistant/.homeassistant/camera_images/doorbell.jpg"}

Current Automation when Doorbell rings

- alias: 'Notify Doorbell Pressed'
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: binary_sensor.doorbell
    from: 'off'
    to: 'on'
  action:
  - service: notify.ios_iphone
    data:
      message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
      data:
        attachment:
          content-type: jpeg
        push:
          category: camera
        entity_id: camera.front_door_camera

Help :slight_smile:

If you want a static camera snapshot image instead of a streaming one, make a “snapshots” directory under the “www” directory where your config is then use:

action:
- service: camera.snapshot
  data_template:
    entity_id: camera.front_door_camera
    filename: "/config/www/snapshots/front_door_camera_{{ trigger.to_state.last_changed }}.jpg"
- service: notify.ios_iphone
  data_template:
    message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
    data:
      attachment:
        content-type: jpeg
        url: "https://hass.yourdomain.com/local/snapshots/front_door_camera_{{ trigger.to_state.last_changed|urlencode }}.jpg"
      entity_id: camera.front_door_camera

Note that /local/ maps to the “www” subdirectory of your config directory.

Thanks for your code. It helped me to implement this. However, I still have a problem. The snapshot file is saved into the snapshots folder correctly but it is not sent with the notification. When I click on the notification, it takes me to HA’s overview page. The url that I am specifying is:
url: “https://mysecreturl.duckdns.org/local/snapshots/...jpg” I am 100% sure that I have the correct filename.
If I go to the snapshots folder and click on the image, it opens on the browser but the url is something like:
https://mysecreturl.duckdns.org/api/hassio_ingress/ALOTOFENCRYPTEDCODEHERE/api/file?filename=/config/www/snapshots/...jpg

I tried entering the entire path above but it doesn’t work. Any help would be greatly appreciated.

You should be able to go to “https://mysecreturl.duckdns.org/local/snapshots/...jpg” from your computer. I just set this up for my wife’s iPhone and it is working.

Yes, it worked! Thanks again for replying and posting your code.