Roon Command Line Control version 2

HI,

can I install the Roon Command Line Control version 2 on another machine than the roon core is installed ?

How can I connect them ?

@Florian Yes, that is the intended deployment. RoonCommandLine does not touch the Roon Core. The installation performs an automatic discovery to connect with the Roon Core. At discovery you will be prompted to authorize the connection in Settings → Extensions

I’ve been trying to install RoonCommandLine_2.0.8-5.deb on Debian 12, and I’m running into an issue (see first blockquote). It looks to me like there’s some problem with installing the roonapi library (see second blockquote).

Is this a known issue, and if so is there a workaround? I previously used RoonCommandLine on Ubuntu 22.04 without any issues. But apparently Debian 12 is sufficiently different that it doesn’t work.

Chris

kleph ~ $ sudo apt install ~/software/downloads/RoonCommandLine_2.0.8-5.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'rooncommandline' instead of '/home/cph/software/downloads/RoonCommandLine_2.0.8-5.deb'
The following additional packages will be installed:
libjs-sphinxdoc libpython3-dev libpython3.11-dev python3-dev python3-pip python3-wheel
python3.11-dev
The following NEW packages will be installed:
libjs-sphinxdoc libpython3-dev libpython3.11-dev python3-dev python3-pip python3-wheel
python3.11-dev rooncommandline
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,874 kB/6,958 kB of archives.
After this operation, 35.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 /home/cph/software/downloads/RoonCommandLine_2.0.8-5.deb rooncommandline all 2.0.8-5 [83.2 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libjs-sphinxdoc all 5.3.0-4 [130 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libpython3.11-dev amd64 3.11.2-6 [4,738 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 libpython3-dev amd64 3.11.2-1+b1 [9,572 B]
Get:5 http://deb.debian.org/debian bookworm/main amd64 python3.11-dev amd64 3.11.2-6 [615 kB]
Get:6 http://deb.debian.org/debian bookworm/main amd64 python3-dev amd64 3.11.2-1+b1 [26.2 kB]
Get:7 http://deb.debian.org/debian bookworm/main amd64 python3-wheel all 0.38.4-2 [30.8 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 python3-pip all 23.0.1+dfsg-1 [1,325 kB]
Fetched 6,874 kB in 3s (2,187 kB/s)
Selecting previously unselected package libjs-sphinxdoc.
(Reading database ... 232055 files and directories currently installed.)
Preparing to unpack .../0-libjs-sphinxdoc_5.3.0-4_all.deb ...
Unpacking libjs-sphinxdoc (5.3.0-4) ...
Selecting previously unselected package libpython3.11-dev:amd64.
Preparing to unpack .../1-libpython3.11-dev_3.11.2-6_amd64.deb ...
Unpacking libpython3.11-dev:amd64 (3.11.2-6) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../2-libpython3-dev_3.11.2-1+b1_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.11.2-1+b1) ...
Selecting previously unselected package python3.11-dev.
Preparing to unpack .../3-python3.11-dev_3.11.2-6_amd64.deb ...
Unpacking python3.11-dev (3.11.2-6) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../4-python3-dev_3.11.2-1+b1_amd64.deb ...
Unpacking python3-dev (3.11.2-1+b1) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../5-python3-wheel_0.38.4-2_all.deb ...
Unpacking python3-wheel (0.38.4-2) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../6-python3-pip_23.0.1+dfsg-1_all.deb ...
Unpacking python3-pip (23.0.1+dfsg-1) ...
Selecting previously unselected package rooncommandline.
Preparing to unpack .../7-RoonCommandLine_2.0.8-5.deb ...
Unpacking rooncommandline (2.0.8-5) ...
Setting up python3-wheel (0.38.4-2) ...
Setting up libpython3.11-dev:amd64 (3.11.2-6) ...
Setting up python3-pip (23.0.1+dfsg-1) ...
Setting up libjs-sphinxdoc (5.3.0-4) ...
Setting up rooncommandline (2.0.8-5) ...
Restoring saved /usr/local/Roon/etc/roon_api.ini
Restoring saved /usr/local/Roon/etc/pyroonconf
Enabling local access in /usr/local/Roon/etc/pyroonconf
Setting the Python Roon API server IP address to 192.168.4.45
Could not locate the roonapi Python module installation directory
Python Roon API patch not applied.
List commands will not function properly.

In order to configure the Python Roon API we must set the IP address
of the Roon Core. Discovery will be used to determine the Roon Core IP.
When prompted for authorization, go to a Roon Remote window and click
Settings → Extensions → Enable
to authorize discovery

Traceback (most recent call last):
File “/usr/local/Roon/api/get_core_ip.py”, line 3, in
from roonapi import RoonApi, RoonDiscovery
ModuleNotFoundError: No module named ‘roonapi’
Traceback (most recent call last):
File “/usr/local/Roon/api/list_zones.py”, line 4, in
from roonapi import RoonApi
ModuleNotFoundError: No module named ‘roonapi’

Verify the ‘server’ and ‘user’ settings in the roon script are correct
and copy the ‘roon’ frontend shell script to a location in your execution
PATH on all systems from which you wish to control Roon via SSH

Edit the Roon Command Line configuration settings at:
/usr/local/Roon/etc/roon_api.ini
and verify the settings in the configuration file /usr/local/Roon/etc/pyroonconf

Setting up libpython3-dev:amd64 (3.11.2-1+b1) …
Setting up python3.11-dev (3.11.2-6) …
Setting up python3-dev (3.11.2-1+b1) …
Processing triggers for man-db (2.11.2-2) …

After trying various things, I noticed this:

kleph ~ $ python3 -m pip install --upgrade roonapi
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

@Chris_Hanson thanks for reporting this. I recently ran into the same issue when attempting to install RoonCommandLine on Ubuntu 22.10. Versions of Ubuntu since, I think, 22.04 require that Python modules be installed in a Python virtual environment.

Apparently Debian 12 is enforcing a similar requirement. It’s a pretty dramatic breakage and effects anything that tries to do a simple python3 -m pip install .... This can be avoided by using pipx rather than pip but pipx doesn’t support installation of libraries and roonapi is a library.

So, I have some work to do to get roonapi to install on platforms that enforce Python virtual environments.

Thanks, I’ll wait until you’ve figured it out.

BTW, I love this software: it’s the only practical solution I’ve found for controlling roon from linux systems, and having it be command-line based means it’s really easy to integrate. I’ve got emacs keystrokes that start and stop the music quickly.

1 Like

@Chris_Hanson a new release of RoonCommandLine that supports installation on Ubuntu 23.04, Debian 12, and later is available at:

https://github.com/doctorfree/RoonCommandLine/releases/tag/v2.1.0r1

This release moves to a Python virtual environment as required by these recent versions of some Linux distributions.

I rushed this release after some initial testing so it may need some further adjustments but I’m listening to Donovan on Roon right now using the roon command so it works for me.

Let me know if you encounter any issue.

@Ronald_Record New release seems better, but not there yet:

kleph ~ $ sudo apt install ~/Downloads/RoonCommandLine_2.1.0-1.deb | tee ~/tmp/rcl.out

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists…
Building dependency tree…
Reading state information…
The following NEW packages will be installed:
rooncommandline
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/83.8 kB of archives.
After this operation, 1,339 kB of additional disk space will be used.
Get:1 /home/cph/Downloads/RoonCommandLine_2.1.0-1.deb rooncommandline all 2.1.0-1 [83.8 kB]
Selecting previously unselected package rooncommandline.
(Reading database … 234170 files and directories currently installed.)
Preparing to unpack …/RoonCommandLine_2.1.0-1.deb …
Unpacking rooncommandline (2.1.0-1) …
Setting up rooncommandline (2.1.0-1) …
Collecting roonapi
Using cached roonapi-0.1.6-py3-none-any.whl (21 kB)
Collecting ifaddr>=0.1.0
Using cached ifaddr-0.2.0-py3-none-any.whl (12 kB)
Collecting requests>=2.0
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting six>=1.10.0
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting websocket_client>=1.4.0
Using cached websocket_client-1.7.0-py3-none-any.whl (58 kB)
Collecting charset-normalizer<4,>=2
Using cached charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (140 kB)
Collecting idna<4,>=2.5
Using cached idna-3.6-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1
Using cached urllib3-2.2.0-py3-none-any.whl (120 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Installing collected packages: ifaddr, websocket_client, urllib3, six, idna, charset-normalizer, certifi, requests, roonapi
Successfully installed certifi-2024.2.2 charset-normalizer-3.3.2 idna-3.6 ifaddr-0.2.0 requests-2.31.0 roonapi-0.1.6 six-1.16.0 urllib3-2.2.0 websocket_client-1.7.0
Collecting rich-cli
Using cached rich_cli-1.8.0-py3-none-any.whl (14 kB)
Collecting click<9.0.0,>=8.0.0
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Requirement already satisfied: requests<3.0.0,>=2.0.0 in /usr/local/Roon/venv/lib/python3.11/site-packages (from rich-cli) (2.31.0)
Collecting rich<13.0.0,>=12.4.1
Using cached rich-12.6.0-py3-none-any.whl (237 kB)
Collecting rich-rst<2.0.0,>=1.1.7
Using cached rich_rst-1.2.0-py3-none-any.whl (11 kB)
Collecting textual<0.2.0,>=0.1.18
Using cached textual-0.1.18-py3-none-any.whl (89 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/Roon/venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.0.0->rich-cli) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/Roon/venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.0.0->rich-cli) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/Roon/venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.0.0->rich-cli) (2.2.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/Roon/venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.0.0->rich-cli) (2024.2.2)
Collecting commonmark<0.10.0,>=0.9.0
Using cached commonmark-0.9.1-py2.py3-none-any.whl (51 kB)
Collecting pygments<3.0.0,>=2.6.0
Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Collecting docutils
Using cached docutils-0.20.1-py3-none-any.whl (572 kB)
Installing collected packages: commonmark, pygments, docutils, click, rich, textual, rich-rst, rich-cli
Successfully installed click-8.1.7 commonmark-0.9.1 docutils-0.20.1 pygments-2.17.2 rich-12.6.0 rich-cli-1.8.0 rich-rst-1.2.0 textual-0.1.18
Restoring saved /usr/local/Roon/etc/roon_api.ini
Restoring saved /usr/local/Roon/etc/pyroonconf
Enabling local access in /usr/local/Roon/etc/pyroonconf
Setting the Python Roon API server IP address to 192.168.4.45

In order to configure the Python Roon API we must set the IP address
of the Roon Core. Discovery will be used to determine the Roon Core IP.
When prompted for authorization, go to a Roon Remote window and click
Settings → Extensions → Enable
to authorize discovery

Traceback (most recent call last):
File “/usr/local/Roon/api/get_core_ip.py”, line 8, in
tokenfile = config[‘DEFAULT’][‘TokenFileName’]

File "/usr/lib/python3.11/configparser.py", line 1273, in __getitem__
raise KeyError(key)
KeyError: 'TokenFileName'
Traceback (most recent call last):
File "/usr/local/Roon/api/list_zones.py", line 10, in <module>
server = config['DEFAULT']['RoonCoreIP']
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/usr/lib/python3.11/configparser.py", line 1273, in __getitem__
raise KeyError(key)
KeyError: 'RoonCoreIP'

Verify the 'server' and 'user' settings in the roon script are correct
and copy the 'roon' frontend shell script to a location in your execution
PATH on all systems from which you wish to control Roon via SSH

Edit the Roon Command Line configuration settings at:
/usr/local/Roon/etc/roon_api.ini
and verify the settings in the configuration file /usr/local/Roon/etc/pyroonconf

Processing triggers for man-db (2.11.2-2) ...

@Chris_Hanson thanks for trying this and providing a detailed report. Looks like it’s back to the drawing board for me.

@Chris_Hanson I believe i’ve fixed that issue. I was able to reproduce it, an issue with restoring a previously saved roon_api.ini but that saved file was corrupt because the previous installation had failed.

While I was in there I found and fixed a few more things with using a Python virtual environment and I expect I will continue to uncover more as I put it through more thorough testing.

If you want to try out this hopefully fixed enough to install without error release, it can be found at https://github.com/doctorfree/RoonCommandLine/releases/tag/v2.1.0r3

Note to others, this new release is not adding any functionality. It is simply trying to deal with new restrictions on installing Python modules in some newer operating environments. You do not need to install it if you are not on Ubuntu 23.04 or Debian 12 or later.

1 Like

All fixed and working. Thanks for the fast response!

I’ve created a new release which primarily contains support for transferring the current queue to another zone. See RoonCommandLine Version 2.1.0 Release 4

This release includes the new command transfer_zone which takes an optional first argument specifying the source zone and a second argument specifying the destination zone name. If no source zone is specified then the first argument is the destination zone. For example, to transfer the current queue from the current active zone to the zone “WiiM Pro Plus” you would enter the command:

transfer_zone "WiiM Pro Plus"

To transfer from zone “HomePod Max” to “WiiM Pro Plus” you would enter:

transfer_zone "HomePod Max" "WiiM Pro Plus"

The roon command can also be used to perform the transfer, acting as a front-end for transfer_zone:

roon -F "HomePod Max" -D "WiiM Pro Plus"

where -F specifies the source zone and -D specifies the destination zone. If no -F is provided then the last played zone is used as the source.

No menu support for this feature exists as yet.

If you try it out let me know how it goes. This was fairly quickly implemented so it has little test time.

3 Likes

Hey.
First of all - Awesome extension…
I’ve spent a few days tinkering with it and can now use google assistant (first tried Siri but sorry… Siri sucks in comparison to understand commands)…
Anyhow, I can now speak to my nest units and send various commands to my Mac (ssh etc), works great… I just today found “triggercmd” which made the whole process to have google voice command trigger to run something on my Mac much easier…

The only thing that frustrates me is that any music added via this is added via some other profile (default?) and I cannot see my own playlists since they where not shared pre- feature removal of being able to show to all.

I did see the suggestion to switch profile earlier in the thread but I have no clue how to make use of it… has anyone tried the “workaround” and could possibly explain how to do it?

If anyone does want to use google assistant and have a Mac with the command line tool installed I man happy to answer questions on how to use triggercmd…

@ Ronald_Record

Hello Ronald,
I tried to install this version on my linux mint.
The installation goes well, obviously ‘roonapi’ is missing.
I don’t think I have to manually install it myself ?

Installing this version of RoonCommandLine will automatically upgrade or install the latest version of the Python Roon API, providing improved volume control especially for those Roon endpoints with dB volume ranges.

Restoring saved /usr/local/Roon/etc/pyroonconf
Enabling local access in /usr/local/Roon/etc/pyroonconf
Setting the Python Roon API server IP address to 192.168.1.43
Could not locate the roonapi Python module installation directory
Python Roon API patch not applied.
List commands will not function properly.

In order to configure the Python Roon API we must set the IP address
of the Roon Core. Discovery will be used to determine the Roon Core IP.
When prompted for authorization, go to a Roon Remote window and click
    Settings -> Extensions -> Enable
to authorize discovery

Traceback (most recent call last):
  File "/usr/local/Roon/api/get_core_ip.py", line 3, in <module>
    from roonapi import RoonApi, RoonDiscovery
ModuleNotFoundError: No module named 'roonapi'
Traceback (most recent call last):

  File "/usr/local/Roon/api/list_zones.py", line 4, in <module>

    from roonapi import RoonApi

ModuleNotFoundError: No module named 'roonapi'


Verify the 'server' and 'user' settings in the roon script are correct
and copy the 'roon' frontend shell script to a location in your execution
PATH on all systems from which you wish to control Roon via SSH

Edit the Roon Command Line configuration settings at:
/usr/local/Roon/etc/roon_api.ini
and verify the settings in the configuration file /usr/local/Roon/etc/pyroonconf

In advance, thank you for your help, dp.

@Dirk-Pitt this may be the result of an upgrade failing to setup the Python virtual environment correctly. Could you check /usr/local/Roon/etc/pyroonconf and verify it contains the following:

export PYTHONUSERBASE=/usr/local/Roon/venv

The Python virtual environment gets installed in /usr/local/Roon/venv/. My suspicion is, due to restoring a previous pyroonconf your system did not get properly upgraded with the Python virtual environment settings used by RoonCommandLine. If so, I will look into why an upgrade would fail to setup the Python virtual environment correctly.

If you can confirm for me that this is the case then I will provide you with instruction on how to perform a reinstall without preserving any pyroonconf. This would be a workaround while I prepare a new release that fixes this issue.

Thank you @Ronald_Record for this quick response.
This is the content of the file /usr/local/Roon/etc/pyroonconf :

ROON_ZONE=""
LOCAL=true

@Dirk-Pitt it looks like an upgrade of RoonCommandLine is not updating pyroonconf correctly. I will fix that but for now I believe you should be able to reinstall following this procedure as a workaround:

sudo apt remove rooncommandline
sudo rm -f /tmp/*roon*.save
sudo apt install ./RoonCommandLine_<version>-<release>.deb

Where ./RoonCommandLine_<version>-<release>.deb is the latest downloaded RoonCommandLine Debian format package. Sorry for the trouble, the next release should address upgrade issues with a Python virtual environment (necessary now because distros are making it so pip install <pkg> no longer works even though a gazillion projects do that).

Let me know if the above procedure works for you on Mint Linux. If not, I will think harder.

@Ronald_Record

Same :

Enabling local access in /usr/local/Roon/etc/pyroonconf
Setting the Python Roon API server IP address to 192.168.1.43
Could not locate the roonapi Python module installation directory
Python Roon API patch not applied.
List commands will not function properly.

In order to configure the Python Roon API we must set the IP address
of the Roon Core. Discovery will be used to determine the Roon Core IP.
When prompted for authorization, go to a Roon Remote window and click
    Settings -> Extensions -> Enable
to authorize discovery

Traceback (most recent call last):
  File "/usr/local/Roon/api/get_core_ip.py", line 3, in <module>
    from roonapi import RoonApi, RoonDiscovery
ModuleNotFoundError: No module named 'roonapi'
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_zones.py", line 4, in <module>
    from roonapi import RoonApi
ModuleNotFoundError: No module named 'roonapi'

Verify the 'server' and 'user' settings in the roon script are correct
and copy the 'roon' frontend shell script to a location in your execution
PATH on all systems from which you wish to control Roon via SSH

Edit the Roon Command Line configuration settings at:
/usr/local/Roon/etc/roon_api.ini
and verify the settings in the configuration file /usr/local/Roon/etc/pyroonconf

You have to know that my linux mint is a fresh install. Thx, dp.

@Dirk-Pitt I cannot reproduce this on Ubuntu Linux. Are you using the latest RoonCommadLine debian package at https://github.com/doctorfree/RoonCommandLine/releases/download/v2.1.0r4/RoonCommandLine_2.1.0-4.deb ? That is, RoonCommandLine version 2.1.0 release 4 ? Previous versions do not handle the required Python virtual environment properly.

If you are using the latest release deb package then the issue seems to be some difference between our environments - Ubuntu vs Mint or maybe Python, idk. I do not have a Mint system but I suspect it is not Mint but likely Python. Or something I am doing wrong in postinstall. Let’s start with Python. Did the RoonCommandLine postinstall create the Python virtual environment in /usr/local/Roon/venv/ and is there an executable /usr/local/Roon/venv/bin/python ?

If so, what do you see when you run the command:

/usr/local/Roon/venv/bin/python -m pip install roonapi

If there is no /usr/local/Roon/venv/bin/python then we have that to explore.

Thanks for helping me debug this, I cannot reproduce it here so your assistance is invaluable.

Yes :
-rw-rw-r-- 1 zabodarski zabodarski 85260 mai 8 14:03 RoonCommandLine_2.1.0-4.deb

Yes :
lrwxrwxrwx 1 root root 7 mai 8 20:08 /usr/local/Roon/venv/bin/python -> python3

/usr/local/Roon/venv/bin/python: No module named pip

No problem, it’s a pleasure.
I’ll stop there for today, see you tomorrow.
Good evening, dp.

@Dirk-Pitt thanks! I believe I know what the problem is and how to fix it thanks to your reporting. It is always a pleasure working with people far East of me because they usually kick off around Noon my time so I get to spend the rest of the day sunbathing and reading undisturbed :slight_smile:

Hopefully I will have a new release with the appropriate fixes for you to try tomorrow. Have a good evening!

1 Like