Hi first of all I wasn’t too sure which category to put this in but here goes.
When someone rings my doorbell which is an ESP8266 which fires off a MQTT message, i’d like my camera which points at the door to take a snapshot and send it as an IOS notification using the home assistant app to my iPhone.
I have had it setup up previously where it sends a notification with a live feed for the camera, which is no good for me as the person that rung the bell may have left by the time I get to view the notification.
I know there is several threads relating to this already but none seem to have a conclusive answer and the ones I’ve tried just send a notification without a snapshot.
My system is based on ubuntu server with everything in docker containers, using the code below the snapshot gets taken and written to the correct path.
- id: test
alias: test
trigger:
- platform: mqtt
topic: HOME/doorbell/status
action:
- service: camera.snapshot
data:
entity_id: camera.hallway
filename: /tmp/snapshot1.jpg
- delay: 5
- service: notify.ios_scotts_iphone
data:
title: Doorbell
message: Somebody is at the door
data:
photo:
- file: /tmp/snapshot1.jpg
capture: Snapshot
This was mostly copied and pasted and then adjusted to fit my use case, I’ll eventually move this automation over to node-red as I like to keep the frontend clean.
- service: notify.ios_myiosdevice
data_template:
message: >
Motion Detected at Front Door
data:
attachment:
content-type: jpeg
url: "https://MYURL/local/cam_captures/porch_{{ as_timestamp(states.automation.camera_motion_push.attributes.last_triggered)|int }}.jpg"
entity_id: camera.porch
This is mine…, formatting may not work I’m on mobile… the snapshot uses the trigger time as the name to save also because it was retaking the pic and Overwriting the pertinent one … I believe you need to be able to access from your www dir…
@Scott_Pavey does that actually work outside your local network?
According to the docs you can only send URLs, not actual attachments. And for the image to be available outside your local network it needs to be in the config/www directory.
The other advantage of doing it this way is that you dont need a delay. By the time you receive the notification link the snapshot will be ready. This is my doorbell snapshot automation:
Hi thanks for the replies, as it happens and probably an oversight is that I don’t want/need my home assistant accessible from outside the network, I use HomeKit / appleTV to control anything I need to externally, of course that means that I won’t get notifications using the home assistant app away from home.
I setup DuckDNS when I used HASSIO and was very straightforward, but now my setup is more complex with the containers and the other components it won’t be as straightforward…
I’ll copy and adapt your automation if I may, I’m guessing replacing the url with my local url should still work when I’m on my home network?
Actually I think you will still be able to receive notifications as the push server can maintain a connection between your phone and HA.
You won’t be able to view or control your system from outside your local network though. And actionable notifications will not work outside your network.
I did move it over to node-red see below, I haven’t had a chance to fine tune it yet but it works as needed, the delay is there to make sure the picture is saved to file before the notification is sent to the iOS app.
I got this to work using your code however when I tap the notification it opens the ios app but that’s it. I was expecting it to show a larger pic from the notification. Is that not the case?
On my iPhone 7 Plus, I press and hold the notification and a larger picture pops up, this may be a feature only of 3D Touch so I don’t know, if I simply tap on the notification it opens the home assistant app
This is correct. My Home Assistant is only working on IPv6 and my iphone when on 4G only does IPv4. Yet I do get HA notifications as per normal. This is awesome actually. Using the iOS app and siri doesn’t work though as it needs a connection direct to the HA Server. I can use Google Assistant as per normal though.