LMSServer¶
Simple python class definitions for interacting with Logitech Media Server. This code uses the JSON interface.
-
exception
LMSTools.server.
LMSConnectionError
¶
-
class
LMSTools.server.
LMSServer
(host='localhost', port=9000)¶ Parameters: - host (str) – address of LMS server (default “localhost”)
- port (int) – port for the web interface (default 9000)
Class for Logitech Media Server. Provides access via JSON interface. As the class uses the JSON interface, no active connections are maintained.
-
get_player_count
()¶ Return type: int Returns: number of connected players >>>server.get_player_count() 3
-
get_player_from_ref
(ref)¶ Return type: LMSPlayer Returns: Instance of player with specified MAC address (or None if player not found) Get a player instance based on the provided MAC address.
-
get_players
()¶ Return type: list Returns: list of LMSPlayer instances Return a list of currently connected Squeezeplayers.
>>>server.get_players() [LMSPlayer: Living Room (40:40:40:40:40:40), LMSPlayer: PiRadio (41:41:41:41:41:41), LMSPlayer: elParaguayo's Laptop (42:42:42:42:42:42)]
-
get_sync_groups
()¶ Return type: list Returns: list of syncgroups. Each group is a list of references of the members. >>>server.get_sync_groups() [[u'40:40:40:40:40:40', u'41:41:41:41:41:41']]
-
ping
()¶ Return type: bool Returns: True if server is alive, False if server is unreachable Method to test if server is active.
>>>server.ping() True
-
request
(player='-', params=None)¶ Parameters: - player ((str)) – MAC address of a connected player. Alternatively, “-” can be used for server level requests.
- params ((str, list)) – Request command
-
rescan
(mode='fast')¶ Parameters: mode (str) – Mode can be ‘fast’ for update changes on library, ‘full’ for complete library scan and ‘playlists’ for playlists scan only Trigger rescan of the media library.
-
rescanprogress
¶ Attr rescanprogress: current rescan progress
-
show_players_sync_status
(get_players=False)¶ Parameters: - get_players – bool
- get_players – (optional) return instance of LMSPlayer (default False)
Return type: dict
Returns: dictionary (see attributes below)
Attr group_count: (int) Number of sync groups
Attr player_count: (int) Number of connected players
Attr players: (list) List of players (see below)
Player object (dict)
Attr name: Name of player Attr ref: Player reference Attr sync_index: Index of sync group (-1 if not synced) Attr player: LMSPlayer instance (only if ‘get_players’ set to True) >>>server.show_players_sync_status() {'group_count': 1, 'player_count': 3, 'players': [{'name': u'Living Room', 'ref': u'40:40:40:40:40:40', 'sync_index': 0}, {'name': u'PiRadio', 'ref': u'41:41:41:41:41:41', 'sync_index': 0}, {'name': u"elParaguayo's Laptop", 'ref': u'42:42:42:42:42:42', 'sync_index': -1}]}
-
sync
(master, slave)¶ Parameters: - master ((ref)) – Reference of the player to which you wish to sync another player
- slave ((ref)) – Reference of the player which you wish to sync to the master
Sync squeezeplayers.
-
version
¶ Attr version: Version number of server Software >>>server.version u'7.9.0'