home-assistant-libs / aioslimproto Goto Github PK
View Code? Open in Web Editor NEWSLIMProto implementation in async python allows you to control squeezebox players (and compatibles)
License: Apache License 2.0
SLIMProto implementation in async python allows you to control squeezebox players (and compatibles)
License: Apache License 2.0
add feature to create synchronized playergroups
shouldn't be hard as all the plumbing (accurate timestamps etc) is already there.
This is the last step I need to switch completely from lms to music-assistant and this slimproto integration here.
I really need a chance to create group of my squeezelite-esp32 clients.
Have no plan how difficult this is but this is really my last puzzle. :)
I am running squeezelite-esp32 on five ESP32-A1S modules. These modules a ready usable for non technical dudes who are not able to solder little boards. :) And easy flashable with usb, a chrome browser and this:
https://raspiaudio.github.io/
(You need to choose I2S and setup then some parameters, thats all)
I think these modules are ideal to enable anyone to build a multiroom system. Unfortunately, I think that lms is too old-fashioned for some users, so slimproto together with homeassistant could be an ideal solution.
When running the example script i receive the following:
2022-07-11 00:34:27,782 ERROR aioslimproto.discovery -- Error occured while trying to parse a datagram from ('192.168.0.111', 3483) - data: b'd\x00\n9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04 \x1e\xa7\\'
Traceback (most recent call last):
File "/Users/noname/aioslimproto/aioslimproto/discovery.py", line 203, in datagram_received
dgram = Datagram.decode(data)
File "/Users/noname/aioslimproto/aioslimproto/discovery.py", line 42, in decode
return ClientDiscoveryDatagram(data)
File "/Users/noname/aioslimproto/aioslimproto/discovery.py", line 62, in __init__
msg = struct.unpack("!cxBB8x6B", data.encode())
struct.error: unpack requires a buffer of 18 bytes
At this time, playback is kept as simple as possible, by just utilizing the "direct stream" feature of SLIMproto.
In other words: the player has to deal with the content if it supports it. If a player does not support a specific codec or HTTPS it will fail to play.
The idea behind this is that the consumer of this library should take care of any needed transcoding. For example the Music Assistant integration for Home Assistant. The downside is that it adds additional complexity for the lib consumer (and probably the enduser too).
We could also implement a minimum transcoding implementation within the lib using ffmpeg or libsoxr:
This might be a requirement to implement player synchronization if we can 't guarantee players to receive the same audio chunks.
Tried to install this integration to try out the new music assistant. Installed squeezelite on a raspberry pi. When adding this integration in home assistant it fails straight away (no error message or config options). In the log is the following:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 339, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/slimproto/__init__.py", line 19, in async_setup_entry
await slimserver.start()
File "/usr/local/lib/python3.9/site-packages/aioslimproto/server.py", line 60, in start
self._socket_servers += await self.cli.start()
File "/usr/local/lib/python3.9/site-packages/aioslimproto/cli.py", line 120, in start
await asyncio.start_server(
File "/usr/local/lib/python3.9/asyncio/streams.py", line 94, in start_server
return await loop.create_server(factory, host, port, **kwds)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1506, in create_server
raise OSError(err.errno, 'error while attempting '
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 9091): address in use
Note that on an earlier attempt, the port in use was actually 3483. I'm running home assistant core 2022.6.4 in a docker container, network set to host, can't find any other binds for port 3483 so not sure why that one failed and afterwards worked, but 9091 is in use by another process (transmission RPC). Can you make the port editable?
Just checked, and looks like these are the ports used (together with 9090) by the slimserver.
The original squeezebox (classic) players have a small display. The content of this display is supposed to be updated over SLIMproto. I did not yet implement any of that display updating magic so the display would probably still be blank.
If there's enough interest we could add the display support to the code.
Not sure if it bring any extra to the table as all newer squeezebox models and the DIY alternatives no longer use slimproto for updating the display but retrieve the info theirselves from CLI.
There appears to be a typo/oversight in client.py
which is causing Ogg Vorbis playback to not work:
aioslimproto/aioslimproto/client.py
Line 184 in a1da245
The format-byte for Ogg should be o
(lowercase "Oh") not 0
(zero) โ see also the Wiki-page referenced in the comment above the definition itself: https://wiki.slimdevices.com/index.php/SlimProto_TCP_protocol.html#Command:_.22strm.22
We could extend the CLI support a bit so that players with a touchscreen/large display can show a bit more info.
At this time only basic player/button controls are implemented.
The HA server is on 192.168.100.10 and I'm running Squeezelite-X on 192.168.100.9.
The Squeezelite-X log output shows it tries to login, but doesn't receive a response after 4 seconds, so it fails:
Connecting to Logitech Media Server
----------------------------------------------------------------------------------------------------
DBUG 19:06:13.952 Lms.ConnectTelnet called (Host=192.168.100.10:9090)
DBUG 19:06:13.952 DisconnectTelnet Called
INFO 19:06:13.952 Telnet.Status: Connecting to 192.168.100.10.
INFO 19:06:13.953 Telnet.Status: Connected.
DBUG 19:06:13.954 TelNet.Connect succeeded [2 ms]
DBUG 19:06:14.018 OnNavigationStarting: about:blank
DBUG 19:06:14.018 OnNavigationCompleted: about:blank
INFO 19:06:14.035 SND (CLI): login SlxUser ******
DBUG 19:06:14.035 ...Wait for login response
ERROR 19:06:18.035 No response to login message.
DBUG 19:06:18.035 DisconnectTelnet Called
INFO 19:06:18.035 Telnet.Status: Disconnecting.
INFO 19:06:18.035 Telnet.Status: Disconnected.
INFO 19:06:18.036 Stop Squeezelite Processes
INFO 19:06:18.041 ConnectAll Complete
INFO 19:06:18.041 Can't connect to LMS Telnet on port=9090. Check Port Number is correct and ensure server password e
nabled for remote connections.
The only entry from aioslimproto is:
DEBUG (MainThread) [aioslimproto.server.jsonrpc] handle request: SlxUser for player login
When running LMS on that same machine, Squeezelite-X connects to it perfectly well, so it's probably not a networking issue on my side.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.