# 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.
```sh
$ 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.
```Python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/rajlaud/pysqueezebox",
"name": "pysqueezebox",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Raj Laud",
"author_email": "raj.laud@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/90/e6/6557ccabe23835f9e3203be1eedf737823cd1bf7bdd74c0316cdd24af7c9/pysqueezebox-0.10.0.tar.gz",
"platform": null,
"description": "# pysqueezebox - Asynchronous control of squeezeboxes\nThis a library to control a Logitech Media Server asynchronously, intended for\nintegration with Home Assistant.\n\nMuch of the code was adapted from the Home Assistant squeezebox integration.\nThe current convention is for all API-specific code to be part of a third\nparty library hosted on PyPi, so I created a separate library.\n\nThe function names track the terms used by the LMS API, so they do not all\nmatch the old Home Assistant squeezebox integration.\n\nThank you to the original author of the squeezebox integration. If it is you,\nplease let me know so I can credit you here.\n\n# Usage\nInstall pysqueezebox from github, or using PyPi via pip.\n```sh\n$ pip3 install pysqueezebox\n```\n\n## Imports\nImport the Server() and Player() classes from this module. You will also need\nto create an aiohttp.ClientSession() that the module will use to communicate\nwith the Logitech Media Server.\n\nYou can use Server.async_get_players() to retrieve a list of connected players,\nor get a specific player using Server.async_get_player(name=\"PlayerName\").\nRemember that any method starting with \"async_\" is a coroutine that must be\npreceded by an await to run.\n\nFor more information on using aiohttp.ClientSession(), see\nhttps://aiohttp.readthedocs.io/en/stable/client_reference.html.\n```Python\nfrom pysqueezebox import Server, Player\nimport aiohttp\nimport asyncio\nSERVER = '192.168.1.2' # ip address of Logitech Media Server\n\nasync def main():\n async with aiohttp.ClientSession() as session:\n lms = Server(session, SERVER)\n player = await lms.async_get_player(name=\"Bedroom\")\n\tawait player.async_update()\n\tprint(player.album)\n\tawait player.async_play()\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(main())\n```\n\n## Player.async_update()\nThe Player object stores information about the current status of the player.\nThis allows you to retrieve the player's properties without any I/O. Remember\nto call Player.async_update() prior to retrieving properties if you want the\nmost up-to-date information.\n\n## Player() class\nMost of the useful functions are in the Player class. More documentation to\nfollow, but in the meantime, the docstrings should be instructive.\n",
"bugtrack_url": null,
"license": "apache-2.0",
"summary": "Asynchronous library to control Logitech Media Server",
"version": "0.10.0",
"project_urls": {
"Homepage": "https://github.com/rajlaud/pysqueezebox"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "90937ec9147479f17d98feda0c3ad10211d35eac5b8cbca8e4643bc2f59935f3",
"md5": "c8364f4647ba3517808db5172be60f48",
"sha256": "07ae53fb265369c0e57ef1f5cc253d3a1cd48a4126b54618150498704e645e94"
},
"downloads": -1,
"filename": "pysqueezebox-0.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c8364f4647ba3517808db5172be60f48",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 22500,
"upload_time": "2024-10-18T21:45:52",
"upload_time_iso_8601": "2024-10-18T21:45:52.944971Z",
"url": "https://files.pythonhosted.org/packages/90/93/7ec9147479f17d98feda0c3ad10211d35eac5b8cbca8e4643bc2f59935f3/pysqueezebox-0.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "90e66557ccabe23835f9e3203be1eedf737823cd1bf7bdd74c0316cdd24af7c9",
"md5": "ce7772deef9ddb0da4e8f78fd7c87c53",
"sha256": "bd05f25071ecbbf8beca844082b6364f9ce49675e0cf9d6790eef7c0f8da115d"
},
"downloads": -1,
"filename": "pysqueezebox-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "ce7772deef9ddb0da4e8f78fd7c87c53",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 28028,
"upload_time": "2024-10-18T21:45:54",
"upload_time_iso_8601": "2024-10-18T21:45:54.656918Z",
"url": "https://files.pythonhosted.org/packages/90/e6/6557ccabe23835f9e3203be1eedf737823cd1bf7bdd74c0316cdd24af7c9/pysqueezebox-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 21:45:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rajlaud",
"github_project": "pysqueezebox",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pysqueezebox"
}