Skip to main content

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


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.11.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysqueezebox-0.11.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysqueezebox-0.11.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for pysqueezebox-0.11.0.tar.gz
Algorithm Hash digest
SHA256 b73fbfbb81131fa190f1a03e4e8ed5f3f4409c70225f83fa5b00b986ee43ac20
MD5 882fb9c79d9716cf74e20938288d3685
BLAKE2b-256 fcb6f012433bb6220771d27a72259983875d7273a0bc3bded696fe269729db01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysqueezebox-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for pysqueezebox-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d89b73a03338bb3d7a1e0c0f755aad44b38d10f8ff6faea41d46af2adc39693f
MD5 9ac878b9b0c32b193fe9e8818b00f473
BLAKE2b-256 ceb7b9326f532e16846d2eae6e7fa861f95176949e13fa06f81bb1fcd1d7c817

See more details on using hashes here.

Supported by

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