music.snapcast
Platypush documentation
music.snapcast
- class platypush.plugins.music.snapcast.MusicSnapcastPlugin(host='localhost', port=1705, **kwargs)[source]
Bases:
Plugin
Plugin to interact with a [Snapcast](https://github.com/badaix/snapcast) instance, control clients mute status, volume, playback etc.
See https://github.com/badaix/snapcast/blob/master/doc/json_rpc_api/v2_0_0.md for further reference about the returned API types.
- get_backend_hosts()[source]
- Returns:
A dict with the Snapcast hosts configured on the backend in the format host -> port
- get_playing_streams(exclude_local=False)[source]
Returns the remote streams configured in the music.snapcast backend that are currently active and unmuted.
- Parameters:
exclude_local (bool) – Exclude localhost connections (default: False)
- Returns:
dict with the host->port mapping.
Example:
{ "hosts": { "server_1": 1705, "server_2": 1705, "server_3": 1705 } }
- group_set_clients(group, clients, host=None, port=None)[source]
Sets the clients for a group on a Snapcast server
- group_set_stream(group, stream_id, host=None, port=None)[source]
Sets the active stream for a group.
- mute(client=None, group=None, mute=None, host=None, port=None)[source]
Set the mute status of a connected client or group
- Parameters:
client (str) – Client name or ID to mute
group (str) – Group ID to mute
mute (bool) – Mute status. If not set, the mute status of the selected client/group will be toggled.
host (str) – Snapcast server to query (default: default configured host)
port (int) – Snapcast server port (default: default configured port)
- set_client_name(client, name, host=None, port=None)[source]
Set/change the name of a connected client
- set_latency(client, latency, host=None, port=None)[source]
Set/change the latency of a connected client
- status(host=None, port=None, client=None, group=None)[source]
Get the status either of a Snapcast server, client or group
- Parameters:
- Returns:
dict.
Example:
"output": { "groups": [ { "clients": [ { "config": { "instance": 1, "latency": 0, "name": "", "volume": { "muted": false, "percent": 96 } }, "connected": true, "host": { "arch": "x86_64", "ip": "YOUR_IP", "mac": "YOUR_MAC", "name": "YOUR_NAME", "os": "YOUR_OS" }, "id": "YOUR_ID", "lastSeen": { "sec": 1546648311, "usec": 86011 }, "snapclient": { "name": "Snapclient", "protocolVersion": 2, "version": "0.15.0" } } ], "id": "YOUR_ID", "muted": false, "name": "", "stream_id": "mopidy" } ], "server": { "host": { "arch": "armv7l", "ip": "", "mac": "", "name": "YOUR_NAME", "os": "YOUR_OS" }, "snapserver": { "controlProtocolVersion": 1, "name": "Snapserver", "protocolVersion": 1, "version": "0.15.0" } }, "streams": [ { "id": "mopidy", "meta": { "STREAM": "mopidy" }, "status": "playing", "uri": { "fragment": "", "host": "", "path": "/tmp/snapfifo", "query": { "buffer_ms": "20", "codec": "pcm", "name": "mopidy", "sampleformat": "48000:16:2" }, "raw": "pipe:////tmp/snapfifo?buffer_ms=20&codec=pcm&name=mopidy&sampleformat=48000:16:2", "scheme": "pipe" } } ] }
- volume(client, volume=None, delta=None, mute=None, host=None, port=None)[source]
Set the volume of a connected client
- Parameters:
client (str) – Client name or ID
volume (int) – Absolute volume to set between 0 and 100
delta (int) – Relative volume change in percentage (e.g. +10 or -10)
mute (bool) – Set to true or false if you want to toggle the muted status
host (str) – Snapcast server (default: default configured host)
port (int) – Snapcast server port (default: default configured port)