Mycroft Community Forum

Sonos controller skill - testing and feedback

My first attempt at making a skill, any feedback will be greatly appreciated

Sonos controller skill

A simple mycroft skill to control sonos speakers

Description

Uses the SoCo library to control sonos speakers

You can set a default speaker in the settings, otherwise a random active speaker will be chosen at initialisation

Examples

  • “sonos play”
  • “sonos pause”
  • “sonos next”
  • “sonos previous”
  • “sonos louder / volume up”
  • “sonos quieter / volume down”
  • “sonos shuffle on”
  • “sonos shuffle off”
  • “sonos playlist playlist_name”
  • “sonos playlist playlist_name in the living room”
  • “sonos play album album_name”
  • “sonos set living room (as active speaker)”
  • “search for sonos speakers”
  • “show album (art)” (requires mycroft-gui)
  • “sonos what’s playing?”

Specific music services (e.g. Spotify) are not (yet) implemented as I do not have any accounts

github

3 Likes

Great work! Will try it soon…

There is another sonos-control-skill, but this wasn’t updated for more than 1,5 years and has no support for Mycroft-GUI.

Hi. I wanna test and can help in development as I have a spotify account. I am completely new to mycroft. I just got a picroft device up and running, I forked your gihub repo and am trying to install the skill using ```` msm install . I think I am missing something in the skill installation process… :slight_smile:

2020-10-13 15:44:01.465 | WARNING  |  9035 | soco.data_structures_entry | DATA STRUCTURE UPGRADE FAIL. Unable to upgrade music library data structure to music service data structure because an entry is missing for DidlFavorite in DIDL_NAME_TO_QUALIFIED_MS_NAME. This should be reported as a bug.
2020-10-13 15:44:01.474 | WARNING  |  9035 | soco.data_structures_entry | DATA STRUCTURE UPGRADE FAIL. Unable to upgrade music library data structure to music service data structure because an entry is missing for DidlFavorite in DIDL_NAME_TO_QUALIFIED_MS_NAME. This should be reported as a bug.
2020-10-13 15:44:01.482 | ERROR    |  9035 | mycroft.skills.skill_loader:_create_skill_instance:271 | Skill __init__ failed with KeyError('resources')
Traceback (most recent call last):

If you are interested in discussing via Slack: https://join.slack.com/t/sonosmycroft/shared_invite/zt-i9k7v004-m0vqLr2q8cXRh4Z_LPb8Ag

hi. there was indeed a problem with one of the commands. Should be fixed now.
Can you try again?

I will try your changes. I think there was another issue, that I workarounded in a branch: https://github.com/lnguyenh/sonos-controller (I forked your repo). Some of my playlists did not have “resources”. But in my fix I think I broke another command. Tonight or tomorrow I will try to get things working with Spotify, and fix the command I broke.

Example of playlists missing a key in a dict.

Try the slack link from my post above if you wanna discuss faster :slight_smile:

Darn, it seems that getting more direct access to spotify (to search, play specific playlist or albums) is not possible anymore via SoCo :


(see the readme here as well: https://github.com/SoCo/SoCo

I didn’t know about the spotify (and other music services) change of policy. Makes me glad to have my music locally :wink:
About your problem with resources, can you elaborate a bit on that? I’ve not seen any playlists that do no have a resource, how would they get played if there’s no location for them? Can you play them through the official sonos app? Are they local music files or part of a music service such as spotify? in case of the latter I fear we can only add a fix to skip importing unsupported playlists.

Hello boxledev
I think it could be easier to discuss either on

I could show you some samples in an easier way, and continue the discussion.

But anyway. Even if I skip the favorites that dont have resources, I get a upnp error when I try to play the first favorite that does have a URI (see the screenshot above, i sed the uri from “broken politics”). I start to feel a bit pessimistic :).
Last thing I tried is to use the “spotipy” python library and ttrying to use soco to play things on sonos from the data I get from spotipy, but so far, no success.