Sonos mp3 playing fails

Hello all,

I have the sonos working under hass for a while now:

image

I made a couple of months ago an automation to let a dog bark when there is movement while we are gone. It worked just fine until the latest update, I don’t know if it is related but it shows the mp3 file but it doesn’t start.

image

This is my code:

Configuration.yaml

media_player:
  - platform: sonos
    hosts: 192.168.1.238
    name: woonkamer

Automation.yaml

  action:
  - service: media_player.play_media
    data:
      entity_id: media_player.woonkamer
      media_content_id: https://www.domain_name:8123/local/dog.mp3
      media_content_type: MUSIC

Thanks in advance,

André

try removing www.domain_name:8123. just use local/dog.mp3

Thanks for replying Petro, unfortunately it is not working. It is showing the mp3 file but it is not playing.

This is what the log is telling me:

Log Details (ERROR)
Thu Feb 15 2018 10:59:45 GMT+0100 (Central Europe Standard Time)

Error executing service <ServiceCall media_player.play_media: entity_id=['media_player.woonkamer'], media_content_id=local/ram.mp3, media_content_type=MUSIC>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/media_player/sonos.py", line 281, in wrapper
    return funct(*args, **kwargs)
  File "/usr/src/app/homeassistant/components/media_player/sonos.py", line 302, in wrapper
    return funct(device, *args, **kwargs)
  File "/usr/src/app/homeassistant/components/media_player/sonos.py", line 1072, in play_media
    self._player.play_uri(media_id)
  File "/usr/local/lib/python3.6/site-packages/soco/core.py", line 105, in inner_function
    return function(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/soco/core.py", line 569, in play_uri
    ('CurrentURIMetaData', meta)
  File "/usr/local/lib/python3.6/site-packages/soco/services.py", line 181, in _dispatcher
    return self.send_command(action, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/soco/services.py", line 404, in send_command
    self.handle_upnp_error(response.text)
  File "/usr/local/lib/python3.6/site-packages/soco/services.py", line 465, in handle_upnp_error
    error_xml=xml_error
soco.exceptions.SoCoUPnPException: UPnP Error 714 received: Illegal MIME-Type from 192.168.1.238

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/src/app/homeassistant/components/media_player/__init__.py", line 403, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/media_player/sonos.py", line 283, in wrapper
    if err.error_code in errorcodes:
TypeError: argument of type 'NoneType' is not iterable

Anyone an idea?

Error executing service <ServiceCall media_player.play_media: entity_id=[‘media_player.woonkamer’], media_content_id=local/dog.mp3, media_content_type=MUSIC>_
_15:23 components/media_player/sonos.py (ERROR)

Thnx in advance

1 Like

From this line in your error it would appear as if the SONOS is rejecting the playback, reason: Illegal MIME-Type:

My guess is that the media content type is not sent to the sonos device correctly. however i don’t have any further experience with that.

Thank you for your answer, I still don’t understand. It worked for 3 months and suddenly it is not anymore. So I don’t think that it is the mime issue actually, I tried other files as well. I agree with you that the Sonos refuses to play the file but I can’t get the finger behind it.

Seems like a bug, I will try fixing that.

Can you file a Github issue with the information, I cannot keep track of bug reports in here?

Thank you for responding, I will file a github issue tonight.

Hello amechio,

I just filed the issue. It is the first time so be gentle if I made some mistakes :sweat_smile:, please tell me if you need some more info.

https://github.com/fluefiske/fluefisker_hass/issues/1

I appreciate your help.

André

I meant the Home Assistant issue tracker: https://github.com/home-assistant/home-assistant/issues … but you don’t have to do that now, I already investigated the issue and it seems to be a configuration problem on your end. The only HA problem I found is that the error message is quite ugly, I will fix that.

Can you try two things?

  1. Replace the URL with a public file, one example I found is https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3

  2. Test access to your local file, for example with: curl -o/dev/null -s -D- https://192.168.1.15:8123/local/dog.mp3

Let me know the results of those tests :+1:

The first one works, but only with your proposal not with my own file allthough the url addressed to my own server works https://www.mydomain.nl:8123/local/dog.mp3

The second one I don’t understand (curl -o/dev/null -s -D-) what you mean so please can you explain it (sorry for being a noob) it is obviously code but when I run it on my Synology it is returning this:

Kind regards,

André

Okay, so media playing works and it is just this barking file that has an issue.

The curl program can fetch a file from the shell and the command line I provided would show headers that should reveal the problem. Maybe try this if you are not on Linux:

curl -O -s -D- https://192.168.1.15:8123/local/dog.mp3

You are doing that right but the output is odd. It might mean that you should use http://192.168.1.15:8123/local/dog.mp3

If that does not work, try adding the -v option for more verbose output.

So I runned what you say

But nothing happens and I still cannot playing the file.

I used http://192.168.1.15:8123/local/dog.mp3 but cannot acces the file, It is playing the sound in the browser if I type this image in Home assistant it is not playing the sound, could it be an permission issue?

image

Hmm this seams more clear, but actually I am not sure how to solve it, do I need to issue a certificate for a local ip adres?

Try to move the file to your www directory inside of your Home Assistant directory and use:

      media_content_id: /local/dog.mp3

This is what I tried many times but it is not working eighter.

Than it must be a permission issue indeed.

As a workaround you could use a dropbox link. Place it in a Dropbox folder, share the file and change the first part of the link to https://dl.dropboxusercontent.com

Complete link looks like this then:

https://dl.dropboxusercontent.com/s/l5qz6gvbks40ysn/Duke%20Nukem%20-%20Something%20smells%20rotten.mp3?dl=0