Invalid data for call_service at pos 2: extra keys not allowed @ data['file']

I’m getting the following error with my automation:

Invalid data for call_service at pos 2: extra keys not allowed @ data['file']

The automation is supposed to snap an image and send it to pushbullet. Here’s the config:

  - alias: test
trigger:
  platform: state
  entity_id: sensor.octoprint_current_state
  from: 'Operational'
  to: 'Printing'
action:
 - service: camera.snapshot
   data:
    entity_id: camera.octoprint
    filename: tmp/octoprint.jpg
 - service: notify.pushbullet
   data:
    message: Det här är en längre text
    title: Det här är en kortare text
   data:
    file: tmp/octoprint.jpg

I notice on your filenames you are using relative paths. Perhaps there is no tmp directory there.
Examples use /tmp Note the slash at the beginning.

Your indentaion is a bit off. Try this:

 - service: notify.pushbullet
   data:
     message: Det här är en längre text
     title: Det här är en kortare text
     data:
       file: tmp/octoprint.jpg
1 Like

Just tried the following. Not working. Same error: 2019-04-29 08:41:56 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.test. Invalid data for call_service at pos 2: extra keys not allowed @ data[‘file’]

  - alias: test
trigger:
  platform: state
  entity_id: sensor.octoprint_current_state
  from: 'Operational'
  to: 'Printing'
action:
 - service: camera.snapshot
   data:
    entity_id: camera.octoprint
    filename: /tmp/octoprint.jpg
 - service: notify.pushbullet
   data:
    message: Test messagetext
    title: Test titletext
   data:
    file: /tmp/octoprint.jpg

Compare your spacing to mine. Look closely at the indentation of the two data: keys. One is in line with service:, one is in-line with message:

 - service: notify.pushbullet
   data:
     message: Test messagetext
     title: Test titletext
     data:   
       file: tmp/octoprint.jpg

Also there are two spaces per indentation, not one.
I’m assuming the - alias: test indentation is a copy/paste error. You need to pay close attention to this. it is important in YAML.

2 Likes