spotifywebapipython.models.device

@export
class Device:

Spotify Web API Device object.

Device(root: dict = None)

Initializes a new instance of the class.

Arguments:
  • root (dict): Spotify Web API JSON response in dictionary format, used to load object attributes; otherwise, None to not load attributes.
Id: str

The device ID.

This ID is unique and persistent to some extent. However, this is not guaranteed and any cached device_id should periodically be cleared out and refetched as necessary.

IsActive: bool

If this device is the currently active device.

IsMuted: bool

True if the player device volume is zero (muted); otherwise, false.

IsPrivateSession: bool

If this device is currently in a private session.

IsRestricted: bool

Whether controlling this device is restricted.

At present if this is "true" then no Web API commands will be accepted by this device.

Name: str

A human-readable name for the device.

Some devices have a name that the user can configure (e.g. "Loudest speaker") and some devices have a generic name associated with the manufacturer or device model.

Example: Kitchen speaker

SelectItemNameAndId: str

Returns a string that can be used in a selection list in the form of "Name (Id)".

This is a helper property, and not part of the Spotify Web API interface.

SupportsVolume: bool

If this device can be used to set the volume.

Type: str

Device type, such as computer, smartphone or speaker.

Example: computer

VolumePercent: int

The current volume in percent.

Range: 0 - 100 Example: 59

@staticmethod
def GetIdFromSelectItem(value: str) -> str:

Returns the Id portion of a SelectItemNameAndId property value.

Arguments:
Returns:

The Id portion of a SelectItemNameAndId property value, or None if the Id potion could not be determined.

@staticmethod
def GetNameFromSelectItem(value: str) -> str:

Returns the Name portion of a SelectItemNameAndId property value.

Arguments:
Returns:

The Name portion of a SelectItemNameAndId property value, or None if the Name potion could not be determined.

def ToDictionary(self) -> dict:

Returns a dictionary representation of the class.

def ToString(self) -> str:

Returns a displayable string representation of the class.