[Music] Squeeze box / Logitech Media Server control

I’d like to see this feature too so let me have a go at completing the skill suggestion template.


Skill name: mycroft-logitechmediaserver

User story:

  • As a Mycroft administrator, I want to configure my Mycroft installation with the network address of my Logitech Media Server (LMS) installation and details of (some of) its connected Music Players
  • As a music lover, I want to use Mycroft to pause and resume music on my Logitech Media Server Music Player(s)
  • As a music lover, I want to use Mycroft to select which music plays on each Music Player
  • As a music lover, I want to use Mycroft to control the volume on each Music Player

What third party services, data sets or platforms will the Skill interact with?

  • A Logitech Media Server installation, typically on the local network, accessed via the HTTP API on port 9000 or the CLI on port 9090.
  • Optionally also (or instead?) the mysqueezebox.com web site (does anybody rely on this without running a local LMS installation?)

Are there similar Mycroft Skills already?

  • spotify-skill
  • pianobar-skill
  • skill-playback-control
  • There’s a growing number of music sources / services - Spotify, Pandora, streaming services from Amazon | Google | Apple, files on a local NAS or similar repository etc. Rather than having a separate Skill for each of those, it would be really cool if there was a single “umbrella” music control Skill which had “plugins” to interface with the various different back-ends.

What will the user Speak to trigger the Skill?

  • [Similar - or even identical - commands to other music player Skills]
  • Play {{playlist_name}} | {{genre_name}} on {{player_name}}
  • Pause {{player_name}}
  • Resume {{player_name}}
  • Next track | Next song
  • Previous track | Previous song
  • [Some means of searching for music - see e.g. the Spotify skill]
  • [Some means of controlling the volume on different Players]

What phrases will Mycroft Speak?

  • [Confirmation of what has been requested - similar to other music player Skills]

What Skill Settings will this Skill need to store?

  • Hostname or IP address of the Logitech Media Server host
  • List of Player Names to be recognised by Mycroft, mapped to their unique IDs as used by LMS (MAC addresses)

Other comments?

  • In principle, it would be possible to host an LMS Player on the same device as is hosting Mycroft (e.g. using the Squeezelite player software). That’s not the only use case though; in fact users interested in this skill are likely to have existing LMS Players (often more than one) and are likely to be more interested in controlling those using Mycroft - at least initially.
  • It’s probably OK to assume that complex interactions like synchronising one player with another and setting alarms etc. will be done via the LMS web interface rather than using Mycroft - at least initially.
  • openHAB has an integration with Logitech Media Server (though it calls it by the old name - Squeezeboxserver). Might provide some implementation hints. See https://www.openhab.org/addons/bindings/squeezebox/

Currently doing local testing of a Squeezebox / Logitech Media Server skill I wrote some weeks ago for covering my own music player needs. It’s inspired by and similar to the other media playback skills and has most of the features I planned to implement initially. It supports volume and playback control of artists, albums, songs, genres, playlists, favorites (including radio channels saved as favorites) and latest podcast episodes (via podcasts app plugin). There’s still room for improvements and some things are a bit hardcoded for my setup but after some more testing, debugging and cleanup I intend to publish it to get help and feedback. The amount of time I can spend on the project is a bit limited right now so please be patient.

3 Likes

Sing out if you need a hand, @JOPS

That sounds super exciting! I am glad to pitch in if you need any help!

1 Like

@JOPS How’s that coming? Can you put up some code?

Hi all, Sorry for the long wait. I’ve experimented with and rewritten some parts of my Squeezebox skill to utilize the CommonPlay system (some new bugs have most likely been introduced in the process but I think it’s time to at least release something).

See https://github.com/johanpalmqvist/skill-squeezebox/ for the current code. You’re very welcome to test, give feedback and create pull requests. I will gladly accept any
help to get this into shape for the official Mycroft repositories.

3 Likes

Wow that’s fantastic. This has been on my wish list forever! Thank you so much!

I installed it and but I’m getting the response that no music services are installed. Does this require 19.02? I will create an issue on github.

Do you have any log files showing which skills Mycroft loaded during startup and are there any error messages?

In addition to this skill you also need the Playback Control skill for Common Play installed: https://github.com/MycroftAI/skill-playback-control/

So far I have only tested on 18.08 but I’ve started to upgrade my instances to 19.02.

OK I found the playback skill

pi@mark_1:~ $ msm list | grep playback
mycroft-playback-control        [installed]

I think this below from the skills log could be the problem. I did end upgrading to 19.02 to try that route which may be the problem.

20:44:45.805 - skill-squeezebox_johanpalmqvist:initialize:24 - INFO - Initializing SqueezeBox Media skill
20:44:45.840 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist.set'
20:44:45.849 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:IdentifyTrack.intent'
20:44:45.852 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:Stop.intent'
20:44:45.856 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:UpdateCache.intent'
20:44:45.859 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeDown.intent'
20:44:45.862 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeHalf.intent'
20:44:45.866 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeMax.intent'
20:44:45.869 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeMute.intent'
20:44:45.872 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeQuarter.intent'
20:44:45.876 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeThreeQuarters.intent'
20:44:45.879 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeUnmute.intent'
20:44:45.882 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeUp.intent'
20:44:45.999 - mycroft.skills.core:load_skill:166 - ERROR - Failed to load skill: skill-squeezebox.johanpalmqvist
  File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 32, in initialize

I suspect it fails to load the settings. Did you go to https://home.mycroft.ai/ to configure the skill?

Regarding 19.02, I just upgraded my test instance and the skill is loading successfully but I haven’t tested it further at this point.

Ahh home.mycroft.ai not updating reliably. My old nemesis. I touched the setting again and bounced the skills service and it like it started correctly. I see some other errors now, but I won’t have more time to test it tonight.
I have a fairly large collection which you mention as a caution in the readme, so I wonder if that could be related to the latest note. I’ll play with it some more tomorrow. It may be working now, but I can’t say for sure.

00:11:18.850 - skill-squeezebox_johanpalmqvist:initialize:24 - INFO - Initializing SqueezeBox Media skill
00:11:18.854 - mycroft.skills.padatious_service:_register_object:113 - DEBUG - Registering Padatious intent: skill-squeezebox.johanpalmqvist:VolumeUnmute.intent
00:11:18.862 - skill-squeezebox_johanpalmqvist:initialize:43 - DEBUG - Speak dialog enabled: False
00:11:18.868 - skill-squeezebox_johanpalmqvist:get_sources:59 - INFO - Loading content
00:11:18.871 - skill-squeezebox_johanpalmqvist:get_sources:61 - DEBUG - Selecting default backend
00:11:18.876 - skill-squeezebox_johanpalmqvist:get_playerid:109 - DEBUG - Requested backend: Kitchen
00:11:18.888 - mycroft.skills.padatious_service:_register_object:113 - DEBUG - Registering Padatious intent: skill-squeezebox.johanpalmqvist:VolumeUp.intent
<players redacted>
    00:11:20.873 - skill-squeezebox_johanpalmqvist:get_playerid:127 - DEBUG - Player confidence: 1.0
    00:11:20.876 - skill-squeezebox_johanpalmqvist:get_playerid:130 - DEBUG - Extracted backend: Kitchen
    00:11:20.913 - skill-squeezebox_johanpalmqvist:load_library_total_duration:167 - INFO - Loading library total duration state
    00:11:20.921 - skill-squeezebox_johanpalmqvist:load_library_total_duration:173 - INFO - Loaded library total duration state
    00:11:20.932 - skill-squeezebox_johanpalmqvist:update_sources_cache:347 - INFO - Library total duration changed. Updating cache.
    00:11:20.966 - skill-squeezebox_johanpalmqvist:load_library_total_duration:167 - INFO - Loading library total duration state
    00:11:20.976 - skill-squeezebox_johanpalmqvist:load_library_total_duration:173 - INFO - Loaded library total duration state
    00:11:20.982 - skill-squeezebox_johanpalmqvist:update_library_cache:324 - INFO - Library total duration unchanged. Not updating cache.
    00:11:20.986 - skill-squeezebox_johanpalmqvist:load_library_cache:157 - INFO - Loading library cache
    00:11:20.990 - skill-squeezebox_johanpalmqvist:load_library_cache:163 - ERROR - Library cache not found. Exception: Expecting value: line 1 column 1 (char 0)
    00:11:21.014 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist.set'
    00:11:21.022 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:IdentifyTrack.intent'
    00:11:21.025 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:Stop.intent'
    00:11:21.029 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:UpdateCache.intent'
    00:11:21.032 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeDown.intent'
    00:11:21.035 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeHalf.intent'
    00:11:21.038 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeMax.intent'
    00:11:21.042 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeMute.intent'
    00:11:21.045 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeQuarter.intent'
    00:11:21.048 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeThreeQuarters.intent'
    00:11:21.053 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeUnmute.intent'
    00:11:21.056 - mycroft.messagebus.client.ws:remove:159 - DEBUG - Removing found 'skill-squeezebox.johanpalmqvist:VolumeUp.intent'
    00:11:21.173 - mycroft.skills.core:load_skill:166 - ERROR - Failed to load skill: skill-squeezebox.johanpalmqvist
      File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 55, in initialize
      File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 65, in get_sources
      File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 348, in update_sources_cache
      File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 234, in save_sources_cache
    AttributeError: 'SqueezeBoxMediaSkill' object has no attribute 'results'

OK it appears to be caching the albums so everything appears to be progressing. I’ll give it a go once that finishes.

One error buried in the logs is:
Failed to load setting file: /opt/mycroft/skills/skill-squeezebox.johanpalmqvist/settingsmeta.json which looks fine. It doesn’t have my settings there, but has the template.

Thanks for everything, this has been one of my most wanted items in Mycroft for a long time!

1 Like

OK it was able to scan through all my music (I think) the final scans were of genre, but the skill won’t load with the following error:

17:46:26.961 - mycroft.skills.core:load_skill:166 - ERROR - Failed to load skill: skill-squeezebox.johanpalmqvist
  File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 55, in initialize
  File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 65, in get_sources
  File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 348, in update_sources_cache
  File "/opt/mycroft/skills/skill-squeezebox.johanpalmqvist/__init__.py", line 296, in save_sources_cache

Re-reading your readme (duh) I’m guessing this may be insurmountable, due to the size of the library.

I’m OK with a skill which would be limited to turning the players on and off and favorites/radio stations, as I can navigate the music in other ways. Would it be possible to create a setting which just scanned favorites or radio stations?

Could the issue be caused by missing genre tags in your media files? I’m not sure how large a library can be before running into issues due to size but the library sources are stored in RAM for faster access. I’ve pushed a new version with more error handling and added configurable sources which makes it possible to just load favorites (or other combinations). Would be interesting to see if you still run into issues with the media library on the latest version (might have to delete the *.json.gz files in the skill folder first to make sure they’re recreated).

Awesome! Thanks so much. I’ll test it out tomorrow and I’m going to post it, unless you want to, on the Slimserver forums https://forums.slimdevices.com/forum.php and maybe we can get some more testers.

@JOPS I was able to remove the media library setting and the skill works! Thank you so much this is great.

As for the library itself. There could easily be junk in the tags (especially genre), but I typically navigate my library via dynamic playlists and favorites so this is good enough. Maybe once I clean up the tags I can retry scanning it again.

Is there a command to just turn on/off a player? I typically sync all my players so I don’t need to play something on them just turn one on or off.

I did notice if it can’t find something in its searching it does say you don’t have a music skill installed. I will play around some more and report back.

Thanks for all your work on this!!!

1 Like

@sanderant: You’re welcome, and thank you very much for the testing and feedback!

With the latest version you should be able to power on/off a player. Never used that feature myself but it was easy to add it to the skill.

The response you get sometimes about not having any music skills installed comes from skill-playback-control which handles CommonPlay so you might want to open an issue there. I’ve gotten it too a few times and guess it responds that way when a music skill either doesn’t find a match or it takes too long to deliver a matching result. Maybe the timeout value could be adjusted in skill-playback-control to mitigate the issue but I also think the wording of the response could be better since a music skill is actually installed.

Feel free to mention what Mycroft can do with this skill in the Slimserver forums since I don’t (yet) have an account there (nor have I ever owned any real Squeezebox hardware, only RPi3 + HiFiBerry).

I’m a long-time LMS user, and I picked up on this skill a few days ago via @sanderant post on the Squeezebox forums. I repurposed a Pi3+ with a Jabra borrowed from work and had some fun getting it all to work, at least with some of the standard skills.

I have installed your Squeezebox skill, and configured it with details of my LMS server and main player. But I just can’t see how to use the skill (I am new to this Mycroft/Picroft thing) - or even check whether it’s functioning, so any pointers would be helpful. For example, where do I find the various logs that I could use to identify the issues? And even, what are the commands to ask Mycroft to play from LMS?

Robert

1 Like

Hey @GrumpyBob the best thing is to check the skills log. The process can be a little frustrating to be sure, but if you can grep the skills log that is where I found the most help.

grep -i squeeze /var/log/mycroft/skills.log | less

2 Likes

Hi JOPS & others
Thank you for the skill!! This would be phenomenal if I could get it to work, but it doesn’t :frowning:
Each time I get following error. Tried to change some things in code, Pi can ping the server and all, so I don’t know where to look from here. (I added the settings debuglog also to the errorlog to make it easier to verify)

20:41:02.073 - mycroft.skills.core:load_skill:123 - INFO - ATTEMPTING TO LOAD SKILL: skill-squeezebox with ID skill-squeezebox
20:41:03.704 - mycroft.skills.settings:_poll_skill_settings:412 - INFO - SqueezeBox Media Skill: Delaying next settings fetch
20:41:04.019 - skill-squeezebox:initialize:24 - INFO - Initializing SqueezeBox Media skill
20:41:04.048 - skill-squeezebox:initialize:33 - ERROR - Settings: {'server': '<IPADDRESS>', 'speak_dialog_enabled': False, 'default_player_name': 'Squeezebox_Radio', 'media_library_source_enabled': True, 'playlist_source_enabled': True, 'podcast_source_enabled': True, 'username': '', 'port': '<PORTOFWEBCLIENT', 'password': '', 'favorite_source_enabled': True}
20:41:04.060 - skill-squeezebox:get_sources:94 - INFO - Loading content
20:41:04.301 - skill-squeezebox:load_library_total_duration:241 - INFO - Loading library total duration state
20:41:04.307 - skill-squeezebox:load_library_total_duration:247 - INFO - Loaded library total duration state
20:41:04.312 - skill-squeezebox:update_sources_cache:444 - INFO - Library total duration changed. Updating cache.
20:41:04.358 - skill-squeezebox:load_library_total_duration:241 - INFO - Loading library total duration state
20:41:04.364 - skill-squeezebox:load_library_total_duration:247 - INFO - Loaded library total duration state
20:41:04.371 - skill-squeezebox:update_library_cache:421 - INFO - Library total duration unchanged. Not updating cache.
20:41:04.381 - skill-squeezebox:load_library_cache:231 - INFO - Loading library cache
20:41:04.389 - skill-squeezebox:load_library_cache:237 - ERROR - Library cache not found. Exception: Expecting value: line 1 column 1 (char 0)
20:41:04.616 - mycroft.skills.core:load_skill:170 - ERROR - Failed to load skill: skill-squeezebox
  File "/opt/mycroft/skills/skill-squeezebox/__init__.py", line 80, in initialize
  File "/opt/mycroft/skills/skill-squeezebox/__init__.py", line 101, in get_sources
  File "/opt/mycroft/skills/skill-squeezebox/__init__.py", line 445, in update_sources_cache
  File "/opt/mycroft/skills/skill-squeezebox/__init__.py", line 308, in save_sources_cache
AttributeError: 'SqueezeBoxMediaSkill' object has no attribute 'results'