Media Player platform for Mopidy

I installed it yesterday but I dont have the link - if I remember correctly since you might be having the same issue from the website tutorial im thinking of - I didn’t copy/paste the full text box from that site you might be on. I split the sudo commands in separate lines but once I copied the entire text box and pasted - it ended up working.

1 Like

Hi,

I installed the integration via HACS, but when I try to add it via the “add integrations” it shows an error when I try to config it. “Cannot Connect to Mopidy host” I used my IP 192.168.1.xx for the hostname. Do I have to start the server first? I already restarted Home Assistant.

Hey there,

This component needs a working mopidy server, which can be installed in your HA server as an addon if you wish.

Check in the thread, there have been people here before you with similar questions.

Hello,

First off, thank you all for using my integration, and providing feedback for the past 3 years!

I am currently re-factoring the integration to take advantage of features introduced in Home assistant (queueing, …), replacing some code that is deprecated, try to make it better, and a bit more future proof in general.

I would really appreciate it if anyone is willing to test my new integration before I release it out into the wild.

Testing it does require knowledge on basic git usage and how to manually install custom components, so you need to be comfortable with that. It is currently not (yet) available in HACS.

I am using it myself, and am happy with the performance and stability. I do not expect it to break your setup. But in the event it does, it is just a matter or putting back your original files.

There is no need to remove your mopidy entities in HA, replacing the files and restarting your ha instance is all that is needed.

Git repo

Branch name feature/compat

Howto

  1. Download and extract or clone the repo to your HA instance or computer
  2. make a backup of your existing mopidy component on your HA instance (just in case)
  3. copy the files to the custom component directory (custom_components/mopidy/)
  4. restart HA

Unfortunately, I cannot offer any compensation for helping out other than making you immortal in the acknowledgements section in the README.

After a Home Assistant upgrade, my Mopidy didn’t work anymore, so I upgraded to the latest version of your integration using HACS.

Now I’m getting this error in my Home Assistant logs:

2023-11-22 12:10:14.586 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up mopidy platform for media_player
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
    await asyncio.shield(task)
  File "/home/homeassistant/.homeassistant/custom_components/mopidy/media_player.py", line 117, in async_setup_entry
    speaker = MopidySpeaker(hass, hostname, port)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/mopidy/speaker.py", line 555, in __init__
    self.__connect()
  File "/home/homeassistant/.homeassistant/custom_components/mopidy/speaker.py", line 587, in __connect
    self.api.add_callback('options_changed', self.__ws_options_changed)
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MopidyAPI' object has no attribute 'add_callback'

Could it be that I am missing a python library that should be installed with pip?

Hey,
Would you mind telling me the version of your Mopidy player?
I’m guessing the integration you installed is v2.2.1?

Hi @bushvin
Thank you very much for your afford and great work! Your integration brings a lot of joy in our daily life, given that we use it to play audio books and music in all rooms :slight_smile:
Would you please add information on how to support your work on your GitHub page? Thank you!

@dikt, you are too kind!
While I do not mind receiving your precious gift, please consider a couple of my favorite charities in stead of donating to me:

But if you only want to donate to me, I now have a ko-fi page, thanks to you :wink:
Cheers!

Thank you! This is excellent, simple install and very easy to link to my Mopidy+Snapcast set up.

I couldn’t follow the directions for search, it was all a little over my head, but being able to search and add to the playlist from HA would certainly be the icing on the cake.

1 Like

Thanks for sharing this, and continuing to develop it @bushvin!

I’ve just installed it and really enjoying it so far!

I was wondering if anyone has been able to interrupt a stream with e.g., TTS, wrapped with a snapshot and resume? My initial attempts were not successful.

According to what I have been reading, the way this works is a bit different with each integration, device, etc. so I thought I might ask here for starters.

In the meantime, I’ll keep plugging away trying to figure it out.

Details (thank you for looking!)

I am piping the output of Mopidy into snapserver, via a named pipe on the same machine, bog standard per the (Snapcast) docs. I can hear music (and/or TTS) on the snapclient(s), and can pause, resume, etc. from HA, just not the way I want/expect from a script (yet). The Mopidy source is SomaFM if that matters (and maybe I will try some other sources as well).

EDIT:

I got it working. For some reason, it wouldn’t work from the ‘Run script’ option inside the 3 dot menu in the scrip edit UI. But it did work once I saved it and called it as a service. And then I had to play with the timing a bit, while watching ‘States’ in ‘Developer tools’.

Next steps will be to parameterize it, possibly set volume of various snapclients (still need to install that integration), etc.

Cheers! :beers:

That is awesome!
Would you mind sharing how you did it (code and stuff), and if you’re ok with it, I can add it to the wiki of the repo

Thanks!

I started writing out a reply here and it became pretty long. Then the power went out here. :scream:

Luckily when I came back the forum software still had a draft copy. :relieved:

But I decided it might be better to start a new thread, so that’s what I did:

DIY F/LOSS “Sonos-alike” (with Snapcast, Mopidy), and dad jokes via TTS (with ducking/restore)

Feel free to copy or post a link to the thread!

Cheers! :beers:

That’s a bummer… fortunately the site kept a draft.

The how to looks awesome, I’m not home for a couple of weeks, so won’t be able to test it myself.