Media Player platform for Mopidy

There, can you pull the latest commit and test, pretty please? :wink:

Great job, works perfectly (until I find something new :slight_smile: ).
Now we’re rolling…

1 Like

Really nice integration, solved my problem to have a distant Raspberry pi Zero playing Spotify onto a Bluetooth speaker.

A small annoying “problem” is that I keep get this error in the HA log:

Source: custom_components/mopidy/config_flow.py:120
Integration: Mopidy (documentation)
First occurred: April 30, 2021, 6:03:54 PM (7 occurrences)
Last logged: 6:27:09 AM

An error occurred connecting to device1.local.:80
	<…>
An error occurred connecting to deviceN.local.:80

The devices are all type off network devices with an IP address, but definitely not Mopidy servers.
Is it possible to suppress this “errors” from popping up in the log?

Hello, How can I remove one data from playlist? I see clear playlist option but I would like remove one item.
And I use mini media player. I see the source changer, but how can I configuring the file changer?

@DenGamle
I have received a contribution on my github repo which may solve your issue. can you pull the latest release and try?

@Atis
This component is not meant to edit your music collection. I suggest you install iris or another mopidy web frontend to manage your collectio.

UPDATE
version 1.4.1

  • bugfix: snapshot and restore player state (thanks AdmiralStipe)
  • better messages when device detected through zeroconf is not a mopidy server
  • formatting (pylint, pep8, pydocstyle)
  • fix zeroconf issues on docker (thanks, @guix77)
  • set name to zeroconf name and port

Hello, I find the bug in new version. Can not work the select source (playlist changer).

I dont like edit music collection. But if I play TTS before the music, and if the music end the mopidy play TTS again.

@Atis

Could you please elaborate on your issues?
Can you write down steps to reproduce for me to check your problem?

development device/ service/

service: media_player.select_source
target:
entity_id: media_player.mopidy_kozpont
data:
source: Radio1

“Nem sikerült meghívni a(z) media_player.select_source szolgáltatást. Unknown error”
Can not call media_player.select_source service.

entity_id: media_player.mopidy_kozpont → ok, play and any control, media selector working but source selector lose

update: source selector published. Select source service working. I do not understant

I have attempted to reproduce the behaviour at your end, but failed.

I don’t understand Hungarian, but I could not match it to any of the errors in the mopidy component.

Could you provide a full trace of the error from your home-assistant.log?
something like this:

2021-05-23 15:37:09 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [548221294240] Could not find Radio1
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 141, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1488, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1523, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 642, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 681, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 679, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 642, in async_select_source
    await self.hass.async_add_executor_job(self.select_source, source)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mopidy/media_player.py", line 655, in select_source
    raise ValueError(f"Could not find {source}")
ValueError: Could not find Radio1

Even though the output will be in Hungarian, it may point me towards to where it errs in the component.

That being said, can you also make sure Radio1 is an element of your player’s souce_list
developer tools >> states
And then select your entity.
it should look like this:

source_list:
  - ' Star-Lord''s Zune (by sunpopecharles)'
  - >-
    Emperors Theme (From "Star Wars: Episode 6 - Return of the Jedi") – James
    Nova (by 81644vvhb98spcvfllj8j3n4e)
  - Fleddy Melculy Radio (by spotify)
  - Fleddy's Dirty 30 (by 116691290)
  - GMM 2020 (by graspopmetalmeeting)
  - Liked from Radio
  - Rauwe Kost (by spotify)
  - Release Radar (by spotify)
  - Smith & Burrows Radio (by spotify)
  - Tenacious D Radio (by spotify)
  - The Desert Sessions Family Tree (by jvnvzzqfg0wpmfd7h99jvzxwc)
  - This Is AC/DC (by spotify)
  - This Is Amon Amarth (by spotify)
  - This Is Black Sabbath (by spotify)
  - This Is Corey Taylor (by spotify)
  - This Is Eagles Of Death Metal (by spotify)
  - This Is Gojira (by spotify)
  - This Is Metallica (by spotify)
  - This Is Motörhead (by spotify)
  - This Is Queens Of The Stone Age (by spotify)
  - This Is Slayer (by spotify)
  - This Is Trivium (by spotify)
  - Xmas2019
  - Your Top Songs 2020 (by spotify)
  - Zwaarste Lijst 2020 (by 1128795968)
  - '[Radio Streams]'
  - test
friendly_name: figrindan@6680
icon: 'mdi:music-note'
supported_features: 458687
device_class: speaker

For instance if I want to play the source This Is AC/DC (by spotify)
I would need to specify this:

service: media_player.select_source
data:
  source: This Is AC/DC (by spotify)
target:
  entity_id: media_player.figrindan_6680

I know, but I write the post I can not see source. But now I see. I dont understand

Do you have any idea In media player card why only view the media browser button? I can not see source selector button. But mini media player Can view source selector but can not view media browser button.

Did you by chance restart Mopidy right before?
I know some mopidy services take time to start up.

Anyway, if you have more logs, I’d be happy to look at it.

No. I didn’t do anything. But mopidy does weird things anyway.

Hi, sorry for late replay. After the update, all the error messages disappeared. Thanks a lot.

1 Like

I’ve been testing the snapshot and restore but the latter seems to have a couple of issues for me, but inconsistent… which is the worst
When the player is on and paused, snapshot seems to work ok, but if the player is playing then sometimes the player restores back to off while still playing, and then sometimes just plays the restored song and stops. Does anyone else encounter this?
I’m planning to use a script to simplify the execution; as below…

local_audio:
    #alias: Run Mopidy local audio file
    sequence:
      # Ensure that audible notifications are allowed.
      - condition: state
        entity_id: input_boolean.audible_notifications
        state: "on"
      # Ensure someone is home
      - condition: state
        entity_id: group.family
        state: home
      # Take a snapshot of the current playlist
      - service: mopidy.snapshot
        target:
          entity_id: media_player.ha_player
      # Set the volume from a parameter, should be a value between .1 and 1.0
      - service: media_player.volume_set
        target:
          entity_id: media_player.ha_player
        data:
          volume_level: "{{ volume }}"
      # Play the media from the input parameter
      - service: media_player.play_media
        target:
          entity_id: media_player.ha_player
        data:
          media_content_id: "{{ media }}"
          media_content_type: music
      # Wait until the file stops playing
      - wait_template: "{{ not is_state('media_player.ha_player', 'playing') }}"
      # Restore the previous playlist from the snapshot
      - service: mopidy.restore
        target:
          entity_id: media_player.ha_player
    mode: queued

Hi,

Thanks for the feedback.

The snapshot and restore features are implemented on HA leve instead of the devices themselves. Which means if HA is restarted or the core is reloaded you may loose your snapshot information.

I’m new to conditions in scripts, but I will try to reproduce your behaviour on my setup. Pretty busy with other projects, so please bear with me.

No restarts, I was literally testing repeatedly while I tidied up the script and tried a few things.
Thanks for working on the feature, I’ll still be using it :+1:

The error is still on me. Snapshot work, restore work (I see in mopidy) but In HA mopidy player can not view the restore data. If I script automatic playing music after restore the HA and mopidy view not playing but music go.
I think restore ok, but I dont understand why playing automatic.

Hi @bushvin !
First of all, thanks for this great integration
Unfortunately, I cannot manage to get it connected (here’s the error message after inputing the values) :
image

I’m running Frenck’s Mopidy Add-on from the official hassio Edge repo (GitHub - hassio-addons/addon-mopidy: Mopidy - Home Assistant Community Add-ons), working fine with these parameters :
image

The MPD configuration works fine to get the Mopidy media_player in HA :

- platform: mpd
  host: 192.168.1.9
  name: Mopidy

But your integration seems to be waaay better ! Would you please point me out how to fix this issue ?

PS : I also tried setting in up thought configuration.yaml for the media_player integration, the entity gets created after a reboot but is showing unavailable…