Can't get Slack Attachments to Work in Automations

I’m having a hard time getting camera snapshots to attach to my Slack notifications. I can get them attached properly from the dev tools, so I’m just doing something wrong in my automation. Here’s the automation:

- id: motion_in_kids_room
  alias: 'Notify if motion in kids room'
  trigger:
    - platform: state
      entity_id: sensor.kids_room_motion
      to: 'on'
  condition:
    - condition: state
      entity_id: sensor.office_motion
      state: 'on'
  action:
    - service: camera.snapshot
      entity_id: camera.kids_room_isa__mirabels_room
      data:
        filename: '/tmp/snapshot_kids_room.png'
    - service: notify.slack
      data:
        file:
          path: '/tmp/snapshot_kids_room.png'
        title: "Kid's Room snapshot"
        message: "Motion in kids room."

And that causes this message to show up in my error logs:

2017-11-18 06:37:45 ERROR (MainThread) [homeassistant.core] Invalid service data for notify.slack: extra keys not allowed @ data['file']. Got OrderedDict([('path', '/tmp/snapshot_kids_room.png')])

The part that really confuses me, though, is that if I post this JSON to notify.slack in the dev tools, it works:

{
  "message":"Motion in kids room.",
  "title":"Kid's Room snapshot",
  "data":{
    "file":{
      "path":"/tmp/snapshot_kids_room.png"
    }
  }
}

So are there different rules for the notify.slack data between automation and the dev tools? What am I missing?

Thanks in advance!

  - alias: Doorbell Away
trigger:
  - platform: state
    entity_id: binary_sensor.doorbell
    from: 'on'
    to: 'off'
condition:
  - condition: state
    entity_id: switch.Home
    state: 'off'
action:  
   - service: shell_command.get_front_jpg
   - service: notify.slack
     data:
      title: Doorbell Rang
      message: DOORBELL RANG
      data:
       file:
        path: /config/blueiris/front.jpg
2 Likes

Thanks! I never would have figured out that you need to have nested data entities.