Automation Notifications

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'

how about adding a 1-2 seconds delay between taking a snapshot and sending it? :wink:

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 believe you have to whitelist any directories that are called like that. I had to do the same thing for my camera snapshot autonations.

homeassistant:
  .
  . 
  .
  whitelist_external_dirs:
    - '/config/www/snapshots'
    - '/config/lovelace_views'

through the UI service this is what I get. Still nothing in /tmp

2019-04-08 21:41:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140350630266528] Received {‘type’: ‘call_service’, ‘domain’: ‘camera’, ‘service’: ‘snapshot’, ‘service_data’: {‘entity_id’: ‘camera.garage’, ‘filename’: ‘/tmp/a1.jpg’}, ‘id’: 26}

2019-04-08 21:41:00 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=camera, service=snapshot, service_data=entity_id=camera.garage, filename=/tmp/a1.jpg>

2019-04-08 21:41:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140350630266528] Sending {‘id’: 26, ‘type’: ‘result’, ‘success’: True, ‘result’: None}

2019-04-08 21:41:05 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/error_log to 10.168.123.159 (auth: True

did you try what i suggested above?

i actually was able to whitelist /usr/share . this is where hassio lives. still no go

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

oh, ok. you didn’t mention that before.

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

haas@haas:/$ sudo find -name garage1.jpg

./var/lib/docker/overlay2/cdc35fef5fabff2aea4940531a447001a5a05165548d828de091c33055248715/diff/tmp/garage1.jpg

./var/lib/docker/overlay2/cdc35fef5fabff2aea4940531a447001a5a05165548d828de091c33055248715/merged/tmp/garage1.jpg

the mystery solved… :wink:

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?

the images: call appears to allow for multiple images to be sent. it is working and tested it a few times now

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 :wink:
anyway, glad it’s working after all.