soco.music_services.accounts module

This module contains classes relating to Third Party music services.

class soco.music_services.accounts.Account[source]

An account for a Music Service.

Each service may have more than one account: see the Sonos release notes for version 5-2

service_type = None

str – A unique identifier for the music service to which this account relates, eg '2311' for Spotify.

serial_number = None

str – A unique identifier for this account

nickname = None

str – The account’s nickname

deleted = None

boolTrue if this account has been deleted

username = None

str – The username used for logging into the music service

metadata = None

str – Metadata for the account

oa_device_id = None

str – Used for OpenAuth id for some services

key = None

str – Used for OpenAuthid for some services

classmethod get_accounts(soco=None)[source]

Get all accounts known to the Sonos system.

Parameters:soco (SoCo, optional) – a SoCo instance to query. If None, a random instance is used. Defaults to None.
Returns:A dict containing account instances. Each key is the account’s serial number, and each value is the related Account instance. Accounts which have been marked as deleted are excluded.
Return type:dict

Note

Any existing Account instance will have its attributes updated to those currently stored on the Sonos system.

classmethod get_accounts_for_service(service_type)[source]

Get a list of accounts for a given music service.

Parameters:service_type (str) – The service_type to use.
Returns:A list of Account instances.
Return type:list