I have configured an automation that sends a notification - with a picture taken from my doorbell camera - to my mobile phone and my wifes (all_phones group) when motion is detected.
About 1-2 times per day I receive a notification with no picture, it contains only the title and message text. My wife always receives the picture in the notification sent to her phone. We both have Android phones with the latest version of the HA app.
I have looked through the logs and the automation trace, but do not see anything out of the ordinary. Any ideas of how to diagnose and fix this?
alias: Doorbell Motion
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.doorbell_motion_detected
from: 'off'
to: 'on'
condition:
- condition: template
value_template: >-
{{ (as_timestamp(now()) -
as_timestamp(states.automation.doorbell_motion.attributes.last_triggered |
default(0)) | int > 60)}}
- condition: time
before: '22:00:00'
after: '06:00:00'
action:
- service: notify.all_phones
data:
title: Motion Detected
message: Front door
data:
channel: Doorbell
importance: max
group: Doorbell
image: /api/camera_proxy/camera.doorbell_cropped
ttl: 0
priority: high
mode: single
I’m not sure if the notify runs parallel to the list of devices it contains. Who’s device is first in the notify list? Is it your wife’s? What happens if you add a small second delay (1 second?) Before the notify to let the snapshot finish before calling the notification.
My wife’s phone is the first device listed in the group (all_phones). Thus I would assume that adding a delay will no have an impact as her device is first to get the notification (by a very small margin) and currently she always gets the picture.
For science, I will try adding a small delay and see how it goes tomorrow.
So I tried a few more things, but I am still getting a few notifications each day that are missing the picture.
Additional things I tried:
Reference each phone separately (with a separate action):
action:
- service: camera.snapshot
data:
filename: /config/www/tmp/snapshot.jpg
target:
entity_id: camera.doorbell_cropped
- service: notify.mobile_app_pixel_3a
data:
message: Front door
title: Motion Detected
data:
channel: Doorbell
importance: max
group: Doorbell
image: /local/tmp/snapshot.jpg
ttl: 0
priority: high
- service: notify.mobile_app_pixel_4a
data:
title: Motion Detected
message: Front door
data:
channel: Doorbell
importance: max
group: Doorbell
image: /local/tmp/snapshot.jpg
ttl: 0
priority: high
mode: single
Add a 1 second delay between the notification action:
action:
- service: camera.snapshot
data:
filename: /config/www/tmp/snapshot.jpg
target:
entity_id: camera.doorbell_cropped
- service: notify.mobile_app_pixel_3a
data:
message: Front door
title: Motion Detected
data:
channel: Doorbell
importance: max
group: Doorbell
image: /local/tmp/snapshot.jpg
ttl: 0
priority: high
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: notify.mobile_app_pixel_4a
data:
title: Motion Detected
message: Front door
data:
channel: Doorbell
importance: max
group: Doorbell
image: /local/tmp/snapshot.jpg
ttl: 0
priority: high
mode: single
The strange things is that after trying these two changes, it is now my wife’s phone that occasionally does not receive the picture. Her phone is the Pixel 3a and it has always been the first in the action list.