Skip to main content

Asynchronous library to control Logitech Media Server

Reason this release was yanked:

errors in alarm support

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysqueezebox-0.9.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

pysqueezebox-0.9.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file pysqueezebox-0.9.0.tar.gz.

File metadata

  • Download URL: pysqueezebox-0.9.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pysqueezebox-0.9.0.tar.gz
Algorithm Hash digest
SHA256 27771c717f1522b547a4953c522a782a1c5a375c0e6dc6f2569cb0bdbb5b1423
MD5 b2032e6bff7e8d72b02d156c4a98e3d4
BLAKE2b-256 04436a93436bbe76701b1fa4e2b5915209c11c42efadd831da47a41825c614fc

See more details on using hashes here.

File details

Details for the file pysqueezebox-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: pysqueezebox-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pysqueezebox-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 020ec88beaa5abaca7f02f97ef2a967e959c6b4c523cee026472fe9d69fae1b2
MD5 cf6f6f04f7360774d8475864ace6cbca
BLAKE2b-256 87273850f60e449eb23f9ea7f814e43ff0e4af324f0210fa85974b0815c931a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page