Can’t define Mopidy MPD as a media player in Home Assistant

Hi

I just installed Mopidy-MPD on a RPi which is connected to my LAN. The installation seems to work fine, however, I can’t manage to add the MPD as a media_player.mpd entity to my HA. I added the following to my configuration.yaml:

media_player:
  - platform: mpd
    host: 192.168.0.42
    port: 6600

And in my HA log I get the following errors:

Logger: homeassistant.components.media_player
Source: components/mpd/media_player.py:133
Integration: Media player (documentation, issues)
First occurred: 5:10:44 PM (1 occurrences)
Last logged: 5:10:44 PM

mpd: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mpd/media_player.py", line 167, in async_update
    await self._connect()
  File "/usr/src/homeassistant/homeassistant/components/mpd/media_player.py", line 121, in _connect
    await self._client.connect(self.server, self.port)
  File "/usr/local/lib/python3.8/site-packages/mpd/asyncio.py", line 165, in connect
    r, w = await asyncio.open_unix_connection(host, loop=loop)
  File "/usr/local/lib/python3.8/asyncio/streams.py", line 111, in open_unix_connection
    transport, _ = await loop.create_unix_connection(
  File "/usr/local/lib/python3.8/asyncio/unix_events.py", line 244, in create_unix_connection
    await self.sock_connect(sock, path)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 501, in _sock_connect
    sock.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    await task
  File "/usr/src/homeassistant/homeassistant/components/mpd/media_player.py", line 174, in async_update
    self._disconnect()
  File "/usr/src/homeassistant/homeassistant/components/mpd/media_player.py", line 133, in _disconnect
    self._client.disconnect()
  File "/usr/local/lib/python3.8/site-packages/mpd/asyncio.py", line 188, in disconnect
    if self.__wfile is not None:
AttributeError: 'MPDClient' object has no attribute '_MPDClient__wfile'

Anyone have any ideas?

Thanks

Have you set Mopidy-MPD"s hostname config to allow access from outside localhost? There’s documentation at GitHub - mopidy/mopidy-mpd: Mopidy extension for controlling playback from MPD clients regarding this.

The error log you provided seems to indicate HA is trying to open a Unix socket connection. Which is odd considering you supplied a host and port. You’d need to ask their support channels why it’s doing that. Mopidy-MPD does support Unix sockets but again, needs to be configured to do so.

Thanks. It turned out that I needed to use the http port and not the server port…
Now I can see in HA media_player.mpd.

I don’t follow that but I guess that’s because I don’t know anything about HA or how it talks to Mopidy. Glad it’s working.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.