Unable to call service to play Mp3 with error required key not provided @ data['media_content_type']

Hi guys,

Just started messing around with HASS yesterday so please bear with me :slight_smile:

So, I managed to call a service through the Services Tab that plays a specific MP3 Sound to my Chromecast Audio when evoked .

However, when I try to add the same service call in Lovelace by adding an Entity Card, it keeps failing with the error required key not provided @ data[‘media_content_type’] .

I am using the exact same settings as I use with the service call from the developers area .

Here is my config for this card :

type: entity-button
tap_action:
  action: call-service
  service: media_player.play_media
service_data: null
entity: media_player.chromecastaudio5245
entity_id: media_player.chromecastaudio5245
media_content_id: http://192.168.0.156:8123/local/audio/cineintro.mp3
media_content_type: music
hold_action:
  action: more-info
show_icon: true
show_name: true 

I have tried both audio/mp3 and music for the media_content_type !!!

However it keeps saying the required key is not provided ?

Anyone can give a hand with this please, seems there is no issue with the indentation or anything .

Thanks !

The error message referring to data[‘media_content_type’] means that it is expecting media_content_type to exist under data. I don’t have HA with me so I can’t check, but I think this card passes service_data as data, so you would expect to see media_content_type indented under it. Something along the lines of:

service_data:
  entity: media_player.chromecastaudio5245
  entity_id: media_player.chromecastaudio5245
  media_content_id: http://192.168.0.156:8123/local/audio/cineintro.mp3
  media_content_type: music

Since I run into the same issue, for posterity’s sake, here’s the properly formatted YAML:

type: entity-button
name: "WAKE UP!"
entity: media_player.google_home1
tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    entity_id: media_player.google_home1
    media_content_id: 'https://www.bands.army.mil/music/buglecalls/play.asp?Reveille.mp3'
    media_content_type: audio/mp3
hold_action:
  action: more-info
show_icon: true
show_name: true 

Useful/fun part is, if you omit “entity_id:” in service_data, the MP3 will play to all media player devices known to HAss.