I’m trying to setup a basic notification when a door is opened, can anyone please tell me why I get two notifications when the door gets opened and another notification when the door gets closed? I would of assumed the automation below would have just notified me once when the door got opened and that’s it and would ignore the door closed state,
- id: '1527990727984'
alias: Front Door
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001f39dd6
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
message: The Front Door is open
service: notify.ios_iphone
I have tried an alert in my configuration.yaml file and that worked but when I opened the door I got an alert that the door was closed and then two alerts that the door was open, this was just from opening the door once and leaving it open. When I closed it I got another three alerts once that the door was open and two that it was now closed.
Have a look at your log for the sensor and check if the sensor is sending more than one state change when you open the door. The sensor could be bouncing on-off-on or off-on-off. If that’s the case a time condition should help. e.g.
- id: '1527990727984'
alias: Front Door
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001f39dd6
from: 'off'
platform: state
to: 'on'
for:
seconds: 2
condition: []
action:
- data:
message: The Front Door is open
service: notify.ios_iphone
I wanted to add a snapshot of my security camera to the notification but it doesn’t seem to be working, does this look correct? I get the notification but no camera image.
- id: '1527990727984'
alias: Front Door
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001f39dd6
for:
seconds: 2
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
message: The Front Door is open
service: notify.ios_iphone
- data:
entity_id: camera.gate
service: camera.snapshot
You can only send links to images in iOS notifications and if accessing them outside your local network they have to be accessible from the internet.
Here’s what I do for my doorbell. When the doorbell is pressed the automation takes a snapshot and stores it in the local ‘www’ folder. It then sends a link to the image in the notification as an attachment. This shows up as an image in the notification, not just the link. The www folder is accessible on the internet as /local via duckDNS. You should leave out the sound unless you have uploaded a wav file with that name to your iOS app using iTunes. There’s also other stuff I do like disabling the automation for 10 seconds so I don’t get flooded with notifications but I have left that out for clarity.
- id: doorbell_alert
alias: 'Doorbell Alert'
trigger:
entity_id: binary_sensor.doorbell
platform: state
to: 'on'
action:
- service: camera.snapshot
data:
entity_id: camera.front
filename: '/config/www/doorbell.jpg'
- service: notify.all_ios_devices
data:
message: Someone has pressed the doorbell.
data:
push:
sound: "Doorbell.wav"
attachment:
url: https://xxMYDOMAINxx.duckdns.org/local/doorbell.jpg
Are you sure it was an iOS notification where you saw that snapshot configuration?
The iOS documentation is pretty clear:
url (Required): The URL of content to use as the attachment. This URL must be accessible from the Internet, or the receiving device must be on the same network as the hosted content.
I am getting the notification but I’m not getting the picture. I can see the jpg is being created in the www folder and can access it with the same URL in the automation…
- id: gate_alert
alias: 'Gate Alert'
trigger:
entity_id: binary_sensor.door_window_sensor_158d0001f37d7e
for:
seconds: 2
from: 'off'
platform: state
to: 'on'
action:
- service: camera.snapshot
data:
entity_id: camera.gate
filename: '/config/www/gate.jpg'
- service: notify.ios_iphone
data:
message: The Gate has been opened
data:
attachment:
url: https://myurl.duckdns.org:8123/local/gate.jpg