Media_player.play_media

Hi all, I would stream music, video to my TV (Sony Androdie) or to my ONKY.

I tryed by Service Data e.g.

{
   "entity_id": "media_player.musikserver", "http://live-icy.gss.dr.dk/A/A29H.mp3":"music"
}


  - alias: 1234 test
    trigger:
      - platform: state
        to: "on"
        entity_id: input_boolean.test2
    action:
      service: media_player.musikserver
      data:
        entity_id: media_player.nursery
        media_id: http://www.soundjay.com/nature/sounds/rain-07.mp3
        media_type: music

…but no change on my TV or at stereo.

Device is connected by the DLNA component.

Thanks in advance! :slight_smile:

This should probably be media_player.play_media

And this should be media_content_id: http://www.soundjay.com/nature/sounds/rain-07.mp3

And this should be media_content_type: music

1 Like

rrrrr*** I did a lot of tests…copy pate mistake… this is my config:

  - alias: 1234 test
    trigger:
      - platform: state
        to: "on"
        entity_id: input_boolean.test2
    action:
      service: media_player.play_media
      data:
        entity_id: media_player.musikserver
        media_id: http://www.soundjay.com/nature/sounds/rain-07.mp3
        media_type: music

I tryed with DLNA, KODI and Onkyo. :frowning:

Error message is: Invalid data for call_service at pos 1: extra keys not allowed @ data[‘media_id’]

That is because there is no such attribute for media_player.play_media called media_id. Read @tjntomas’s post.

Thanks! I updated the automation and now I got following error. You have any help for me?

  - alias: "con2 media_player.musikserver"
    trigger:
      - platform: state
        to: "on"
        entity_id: input_boolean.test2
    action:
      service: media_player.play_media
      data:
        entity_id: media_player.musikserver
        media_content_id: http://www.soundjay.com/nature/sounds/rain-07.mp3
        media_content_type: music

Log Details (ERROR)
Sat May 18 2019 21:14:46 GMT+0200 (Mitteleuropäische Sommerzeit)
Error while executing automation automation.con2_media_player_musikserver. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/components/automation/init.py”, line 378, in action
await script_obj.async_run(variables, context)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py”, line 131, in async_run
await self._handle_action(action, variables, context)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py”, line 210, in _handle_action
action, variables, context)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/script.py”, line 299, in _async_call_service
context=context
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 89, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1141, in async_call
self._execute_service(handler, service_call))
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1163, in _execute_service
await handler.func(service_call)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py”, line 194, in handle_service
required_features
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 316, in entity_service_call
future.result() # pop exception if have
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py”, line 339, in _handle_service_platform_call
await func(entity, data)
File “/home/pi/homeassistant/lib/python3.5/site-packages/homeassistant/components/dlna_dmr/media_player.py”, line 334, in async_play_media
media_id, title, mime_type, upnp_class)
File “/home/pi/homeassistant/lib/python3.5/site-packages/async_upnp_client/profiles/dlna.py”, line 627, in async_set_transport_uri
CurrentURIMetaData=meta_data)
File “/home/pi/homeassistant/lib/python3.5/site-packages/async_upnp_client/client.py”, line 511, in async_call
(status_code, response_body))
async_upnp_client.client.UpnpError: Error during async_call(), status: 500, body: <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/” s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”><s:Body><s:Fault>s:ClientUPnPError501Action Failed</s:Fault></s:Body></s:Envelope>

Home Assistant encountered a problem while attempting to play the media on your DLNA device.

What device is the player?

1x Sony Bravia TV (Smart TV with Androide)
1x Onky TX-8150

I tryed, direct to select the device, DLNA and Kodi…

Which component? There are 67 different media_player components.

Here are my media config:

  • platform: onkyo
    host: 192.168.x.xx
    name: onkyo_receiver
    max_volume: 50
    sources:
    dab: “Radio”
    network: “Internet”
    cd: “CD Player”
    dlna: “DLNA”
    usb: “USB-Port”

You really need to learn how to post your code properly.

So you are trying to play to this device. What is it? ie what device?

What do you get when you put the url into your browser, or fetch it with curl or wget?

Please

       for

mat
your

            - code

so

  •   it           is 
    

easier

for others

  • to read
2 Likes

Firmware Update of my Onkyo was the solution :slight_smile:

Thanks to all and for my next post, I try my best for publishing the code .

How is this a “solution”?

No one knows what version of Onkyo firmware you were using nor what version you now have.

More details would be appreciated.

Sure :wink:

Device: Onky TX-8150
Firmware update to 1040-2000-0000
HA Component: DLNA

Test by the service dev tool :

{
  "entity_id": "media_player.onkyo_receiver",
  "media_content_type": "music",
  "media_content_id": "http://live-icy.gss.dr.dk/A/A12H.mp3"
}

If it helps someone with the same media_player.media_play error or “extra keys not allowed” error, when you add a new action on an automation (via Home Assistant (0.103.5) automation wizard, not YAML) on Actions “Services” drop down box there are both media_player.media_play and media_player.play_media items.

As @tjntomas said, you should use media_player.play_media with this attributes

3 Likes

Hi. Sorry to reply to this old thread, but I’m having troubles to do something same you have done.

I have Onkyo TX-NR609 (2011). I’m not sure, which combination of HA components you are using, when you got this working. Are you using Onkyo platform? DLNA-dmr platform? If the latter one, what is the url in your config?