Going to preface this by saying I have opened a few issue lately for interesting problems I am having. Below is another one.
I created a doorbell sensor (door sensor) that I am trying to tie an automation to. The automation is to send a picture from an IP camera via email. The email is being sent but nothing is being attached. Within info in HA, no errors are logged.
Configuration.yaml
camera:
#platform: mjpeg
platform: generic
name: garage
#mjpeg_url: http://10.0.6.174/Streaming/Channels/2/picture
still_image_url: http://10.0.6.174/Streaming/Channels/2/picture
username: someuser
password: yaright
Automation.yaml
- alias: 'Doorbell Notify'
trigger:
- platform: state
entity_id: binary_sensor.Entrance_Door
from: "1"
to: "2"
action:
- service: camera.snapshot
data:
entity_id: camera.garage
filename: "/tmp/frontdoor.jpg"
- service: notify.gmailnotifier
data:
data:
file: "/tmp/frontdoor.jpg"
title: 'Doorbell'
message: 'Here who is at the front door'
I added 3 seconds and nothing. Im also not getting a file in the /tmp directory. I added that as a virtual path to configuration.yaml. Here is the logging from info
2019-04-08 16:40:56 INFO (MainThread) [homeassistant.components.automation] Executing Doorbell Notify
2019-04-08 16:40:56 INFO (MainThread) [homeassistant.helpers.script] Script Doorbell Notify: Running script
2019-04-08 16:40:56 INFO (MainThread) [homeassistant.helpers.script] Script Doorbell Notify: Executing step call service
2019-04-08 16:40:57 INFO (MainThread) [homeassistant.helpers.script] Script Doorbell Notify: Executing step delay 0:00:03
2019-04-08 16:41:01 INFO (MainThread) [homeassistant.helpers.script] Script Doorbell Notify: Executing step call service
Well, you need to play with the camera.snapshot service then and make it create a file - try to call it from UI and see if it makes any difference, for example.
And when it works, replace delay with some wait_template that detects that a file is created (and not empty).
I think you need to whitelist the specific directory where you are storing the snapshots. Even tho my snapshot directory was inside my config directory I still had to whitelist it specifically.
I am writing my snapshots out to /tmp . In the whitelist I included /tmp . Once I get time in the next few days Im going to build another home assistant server. This one has had some hiccups
I decided to dig into the OS more and found my image. It appears to be in the tmp directory in the docker container. First time doing anything docker. got to figure out how to work with this
got it working. This is my first time using docker. Below is my final config. Had to use the docker folder structure that I am able to access from the host. Not sure where I have to use " " and ’ '. Just learning the yaml structure.
- alias: 'Doorbell Notify'
trigger:
- platform: state
entity_id: binary_sensor.Entrance_Door
from: "1"
to: "2"
action:
- service: camera.snapshot
data:
entity_id: camera.garage
filename: "/config/tmp/frontdoor.jpg"
- delay: '00:00:07'
- service: notify.gmailnotifier
data:
data:
images:
- /config/tmp/frontdoor.jpg
title: 'Doorbell'
message: 'Here who is at the front door'
you can use either of them, but keep in mind that if inside there is a pair of single quotes already, you need to use double quotes to surround the whole template, for example, or vice cress.
I’m a bit confused by a dash in front of your images section - is that working right?
oh, I see.
still, the indentation doesn’t seem quite right (- and the rest should be more indented) to me. python and yaml are both all about indentation, and doing wrong may cost you some hair on your head
anyway, glad it’s working after all.