Poor Man Ring IOS Snapshoot issue

Ok, trying to build a PMR (Poor Man Ring) starting from an already working Doorbell button (433Mhz sending signal to a tamotized Sonof Bridge).
It works, alexa announces visitor and I get a notification on the phone, also a snapshot of the nearest camera gets saved in /config/tmp
All smooth except I can’t figure out how to include that snapshot with the IOS notification.

Any help?

   - alias: 'New Doorbell'
    hide_entity: true
    trigger:
    - platform: state
    entity_id: binary_sensor.new_doorbell
    to: 'on'
    action:
    - service: media_player.alexa_tts
    data:
    entity_id: media_player.echo_show
    message: "Test new Door Bell" 
    - service: camera.snapshot
    data:
    entity_id: camera.patio_camera
    filename: '/config/tmp/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
    - service: notify.ios_iphone 
    data:
    message: New Doorbell
    data:
    push:
    category: 'camera'
    entity_id: camera.patio_camera
    attachment:
    file: /config/tmp/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
    content-type: jpg
    hide-thumbnail: false 
    - service: mqtt.publish
    data:
    topic: tele/RF_Bridge/RESULT
    payload: 222B02off

This below works:

- service: notify.ios_iphone 
data:
message: New Doorbell
data:
push:
category: camera
entity_id: camera.patio_camera

Please read the blue banner at the top of the page and edit your post accordingly.

Here’s my PMR to assist you by example. Note the directories. They are important. The image must be accessible from the internet or you must the on the same network as the folder.

/www = internet accessible folder and is mapped to /local in the URL.

- id: doorbell_alert
  alias: 'Doorbell Alert'  
  trigger:
    entity_id: binary_sensor.doorbell
    platform: state
    to: 'on'
  condition:
    condition: template
    value_template: "{{ (as_timestamp(now()) - as_timestamp(state_attr('automation.doorbell_alert', 'last_triggered') | default(0)) | int > 5)}}" # only annoy me again after 5 seconds
  action:
  - service: switch.turn_on
    entity_id: switch.downstairs_doorbell
  - service: switch.turn_on
    entity_id: switch.upstairs_doorbell
  - service: camera.snapshot
    data:
      entity_id: camera.front
      filename: '/config/www/doorbell.jpg'
  - service: switch.turn_off
    entity_id: switch.downstairs_doorbell
  - service: switch.turn_off
    entity_id: switch.upstairs_doorbell
  - service: notify.ios_iphonex
    data:
      message: Someone has pressed the doorbell.
      data:
        push:
          sound: "Doorbell.wav"
        attachment:
          url: https://mydomain.duckdns.org/local/doorbell.jpg
          content-type: jpg
          hide-thumbnail: false
1 Like

Thank you Kindly Tom!

Got it working and I am now trying to keep the old snapshots and only send the latest one but I am confused on the syntax for the ios attachment part.

 - alias: 'Patio Doorbell'
hide_entity: true
trigger:
- platform: state
  entity_id: binary_sensor.patio_doorbell
  to: 'on'
action:
- service: media_player.alexa_tts
  data:
    entity_id: media_player.echo_show_2
    message: 'Someone is at the patio door and doesn't look good'
- service: camera.snapshot
  data:
    entity_id: camera.patio_camera
    filename: '/config/www/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
- service: notify.mobile_app_joes_phone  
  data:
    title: "Doorbell"
    message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
    data:
      attachment:
        content-type: jpg
        url: 'https://myha:8123/local/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg'
        hide-thumbnail: false
- service: mqtt.publish
  data:
    topic: tele/RF_Bridge/RESULT
    payload: xxxxxxx

It’s a template. So this:

- service: notify.mobile_app_joes_phone  
  data:

needs to be:

- service: notify.mobile_app_joes_phone  
  data_template:

Likewise for your snapshot service data.

I then get the error
Invalid config for [automation]: template value is None for dictionary value @ data[‘action’][2][‘data_template’][‘data’]. Got None. (See /config/configuration.yaml, line 491). Please check the docs at https://home-assistant.io/components/automation/

Note that the snapshot service works, the jpg is created in the folder

Please post your amended config, the one that fails.

Here we go I made some little change, tried png instead of jpeg but config is now valid, still no picture attached.
I am using the IOS Beta 2 if that makes any difference.
I see the notification on the phone with date and time and file is created in the folder and it is accessible from outside.

  • alias: ‘Patio Doorbell’
    hide_entity: true
    trigger:
    • platform: state
      entity_id: binary_sensor.patio_doorbell
      to: ‘on’
      action:
    • service: media_player.alexa_tts
      data:
      entity_id: media_player.echo_show_2
      message: ‘test’
    • service: camera.snapshot
      data_template:
      entity_id: camera.patio_camera
      filename: ‘/config/www/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.png’
    • service: notify.mobile_app_joes_phone
      data_template:
      title: “Doorbell”
      message: 'Someone has pressed the patio door bell at {{now().strftime("%H:%M %d-%m-%y")}} ’
      data:
      attachment:
      url: ‘https://XXXXXXXXXXX.duckdns.org:8123/local/patio/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.png’
      content-type: png
      hide-thumbnail: false
    • service: mqtt.publish
      data:
      topic: tele/RF_Bridge/RESULT
      payload: XXXXXX

Please format it correctly.

1 Like

It is a bug of Beta 2.0 still present on build 60

https://github.com/home-assistant/home-assistant-iOS/issues/362#issuecomment-497216663

Update: the code works, I have reverted back to version 55 of the beta 2.0 App.
Hope this helps others, I will write a separate post and a tutorial.
Next step is to add cast to Google Nest Hub (already possible just I have to figure out the proper way) and possibly Alexa show in the future.
Another advantage is that timestamped pictures are stored everytime a doorbell is pushed or the door opens or the gate opens.
It is also possible a custom sound.

  • alias: ‘Patio Doorbell’
    hide_entity: true
    trigger:
    • platform: state
      entity_id: binary_sensor.patio_doorbell
      to: ‘on’
      action:
    • service: media_player.alexa_tts
      data:
      entity_id: media_player.echo_show_2
      message: “Patio Door Bell”
    • service: camera.snapshot
      data_template:
      entity_id: camera.patio_camera
      filename: ‘/config/www/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg’
    • service: notify.mobile_app_joes_phone
      data_template:
      title: “Doorbell”
      message: 'Patio at {{now().strftime("%H:%M %d-%m-%y")}} ’
      data:
      attachment:
      url: ‘https://xxxxxxxxxxx.duckdns.org:0321/local/patiocamera_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg’
      content-type: png
      hide-thumbnail: false
    • service: mqtt.publish
      data:
      topic: tele/RF_Bridge/RESULT
      payload: xxxxxxxxx