Asynchronous library to control Logitech Media Server
Project description
pysqueezebox - Asynchronous control of squeezeboxes
This a library to control a Logitech Media Server asynchronously, intended for integration with Home Assistant.
Much of the code was adapted from the Home Assistant squeezebox integration. The current convention is for all API-specific code to be part of a third party library hosted on PyPi, so I created a separate library.
The function names track the terms used by the LMS API, so they do not all match the old Home Assistant squeezebox integration.
Thank you to the original author of the squeezebox integration. If it is you, please let me know so I can credit you here.
Usage
Install pysqueezebox from github, or using PyPi via pip.
$ pip3 install pysqueezebox
Imports
Import the Server() and Player() classes from this module. You will also need to create an aiohttp.ClientSession() that the module will use to communicate with the Logitech Media Server.
You can use Server.async_get_players() to retrieve a list of connected players, or get a specific player using Server.async_get_player(name="PlayerName"). Remember that any method starting with "async_" is a coroutine that must be preceded by an await to run.
For more information on using aiohttp.ClientSession(), see https://aiohttp.readthedocs.io/en/stable/client_reference.html.
from pysqueezebox import Server, Player
import aiohttp
import asyncio
SERVER = '192.168.1.2' # ip address of Logitech Media Server
async def main():
async with aiohttp.ClientSession() as session:
lms = Server(session, SERVER)
player = await lms.async_get_player(name="Bedroom")
await player.async_update()
print(player.album)
await player.async_play()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Player.async_update()
The Player object stores information about the current status of the player. This allows you to retrieve the player's properties without any I/O. Remember to call Player.async_update() prior to retrieving properties if you want the most up-to-date information.
Player() class
Most of the useful functions are in the Player class. More documentation to follow, but in the meantime, the docstrings should be instructive.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysqueezebox-0.5.5.tar.gz
.
File metadata
- Download URL: pysqueezebox-0.5.5.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93e6a3824b560d4ea2b2e5f0a67fdf3b309b6194fbf9927e44fc0d12c7fdc6c0 |
|
MD5 | 60f2a029e601526b248a2f44d12fe10d |
|
BLAKE2b-256 | c2a9526412fc5d504395c592f4f99d0ac74518bdf54eb3ddf618935f9ed0a5b3 |
File details
Details for the file pysqueezebox-0.5.5-py3-none-any.whl
.
File metadata
- Download URL: pysqueezebox-0.5.5-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f1c900ec2557a8752398519c1a186b332db2d28bcf94102374b01b53d222a5 |
|
MD5 | 8252ea24ed934b9d4e42e201e0c49d7d |
|
BLAKE2b-256 | 9acc953690e6597a4937cdadfce654167d87cec649ec9ef34d233ced637e3b50 |