Play mp3 file (in google drive) as action for automation

Hi

I know there are many other threads on this topic, but can’t figure out what I’m doing wrong… Here is the config:

Here is the error message:
Invalid config for [automation]: [media_content_id] is an invalid option for [automation]. Check: automation->action->0->media_content_id. (See /config/configuration.yaml, line 113).

thanks for your help !!

1 Like

You need to properly format your code per the blue box at the top of the page.nits likely an indentation error but we can’t find it if we can’t see your real code format.

My bad, here is :

- id: '1546775842539'
  alias: Welcome
  trigger:
  - entity_id: light.ampoule_plafond
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - service: media_player.media_play
    entity_id: media_player.google_home
    media_content_id: https://drive.google.com/open?id=1Zx6YOn2m1eLSNy9pm-OoJcoJEtYf-he-
    media_content_type: music

you need to add data: to the service call. I think this should work:

action:
  - service: media_player.media_play
    data:
      entity_id: media_player.google_home
      media_content_id: https://drive.google.com/open?id=1Zx6YOn2m1eLSNy9pm-OoJcoJEtYf-he-
      media_content_type: music

Did just that, no error in code (Thanks !). However, still nothing when I trigger the automation… weird…
would you know how to map it through the Raspberry Pi’s local disk instead of google drive?

You can’t play a local mp3. It can only play externally based files.

Try changing the media content type to mp3.

Other than that I don’t use Google drive so I don’t know what the correct url syntax would be for that.

Did this ever get solved? And why cant a local file be played?

You need to use the following service:
media_player.play_media
and not media_player.media_play

I have found the solution on this web:

Basically, you should extract the id of your drive link and use the following link:

http://docs.google.com/uc?export=open&id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

And:

media_content_type: audio/mp3

Good luck,

1 Like

nice work
thanks