Roon Command Line Control version 2

@Dirk-Pitt a new release of RoonCommandLine is available that hopefully addresses your installation issue. Download https://github.com/doctorfree/RoonCommandLine/releases/download/v2.1.0r5/RoonCommandLine_2.1.0-5.deb and install using the documented procedure.

I’ve tested this new release installation successfully but do not have a platform on which I can reproduce your error. Let me know, if you have time to install this new release, how it goes and if there continues to be a problem on your system or if it resolves that issue.

1 Like

@Ronald_Record
Understood, thank you very much Ronald.
Since I don’t have anything on it, I’m going to reinstall my linux mint from scratch and do the test …
See you later, dp.

@Ronald_Record

Hello Ronald, I’m really sorry but this still doesn’t work.
I did the checks you suggested yesterday :

zabodarski@plitvice:~/TΓ©lΓ©chargements$ ls -al
total 92
drwxr-xr-x  2 zabodarski zabodarski  4096 mai    9 10:59 .
drwxr-x--- 18 zabodarski zabodarski  4096 mai    9 10:58 ..
-rw-rw-r--  1 zabodarski zabodarski 85448 mai    9 10:59 RoonCommandLine_2.1.0-5.deb

zabodarski@plitvice:~$ ls -al /usr/local/Roon/venv
total 24
drwxr-xr-x 5 root root 4096 mai    9 11:01 .
drwxr-xr-x 7 root root 4096 mai    9 11:01 ..
drwxr-xr-x 2 root root 4096 mai    9 11:01 bin
drwxr-xr-x 2 root root 4096 mai    9 11:01 include
drwxr-xr-x 3 root root 4096 mai    9 11:01 lib
lrwxrwxrwx 1 root root    3 mai    9 11:01 lib64 -> lib
-rw-r--r-- 1 root root   71 mai    9 11:01 pyvenv.cfg

zabodarski@plitvice:~$ ls -al /usr/local/Roon/venv/bin/
total 8
drwxr-xr-x 2 root root 4096 mai    9 11:01 .
drwxr-xr-x 5 root root 4096 mai    9 11:01 ..
lrwxrwxrwx 1 root root    7 mai    9 11:01 python -> python3
lrwxrwxrwx 1 root root   16 mai    9 11:01 python3 -> /usr/bin/python3
lrwxrwxrwx 1 root root    7 mai    9 11:01 python3.10 -> python3

zabodarski@plitvice:~$ /usr/local/Roon/venv/bin/python -m pip install roonapi
/usr/local/Roon/venv/bin/python: No module named pip

I will send you the complete installation logs by PM. That said, they are in French. If this is a problem for you, I can reinstall linux mint in English version. Keep me informed …

dp.

@Dirk-Pitt it looks like pip is not getting installed. Can you run the following as root or with sudo?

#!/bin/bash

PYTHON="/usr/bin/python3"
ROON="/usr/local/Roon"
[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[[ ":$PATH:" == *":/usr/local/Roon/venv/bin:"* ]] || {
  export PATH=/usr/local/Roon/venv/bin:${PATH}
}
[ -x ${ROON}/venv/bin/python ] && export PYTHON=${ROON}/venv/bin/python
${PYTHON} -m ensurepip --upgrade

Save that as some file, say /tmp/piptest.sh then make it executable and run it with sudo:

chmod 755 /tmp/piptest.sh
sudo /tmp/piptest.sh

Let me know what is the output from running that test script.

@Ronald_Record

zabodarski@plitvice:/tmp$ chmod 755 /tmp/piptest.sh
zabodarski@plitvice:/tmp$ ls -al /tmp/piptest.sh
-rwxr-xr-x 1 zabodarski zabodarski 340 mai    9 15:56 /tmp/piptest.sh
zabodarski@plitvice:/tmp$ cat /tmp/piptest.sh
#!/bin/bash

PYTHON="/usr/bin/python3"
ROON="/usr/local/Roon"
[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[[ ":$PATH:" == *":/usr/local/Roon/venv/bin:"* ]] || {
  export PATH=/usr/local/Roon/venv/bin:${PATH}
}
[ -x ${ROON}/venv/bin/python ] && export PYTHON=${ROON}/venv/bin/python
${PYTHON} -m ensurepip --upgrade
zabodarski@plitvice:/tmp$ sudo /tmp/piptest.sh
[sudo] Mot de passe de zabodarski :          
/usr/local/Roon/venv/bin/python: No module named ensurepip

@Dirk-Pitt thanks for hanging in there with me. The ensurepip module is the standard way to install pip. I do not know why a fresh Linux Mint install would not have ensurepip. The second way the pip doc says to install pip is with a script you can download and run with python. Let’s try that.

Again, as root or with sudo, save the following as some file, say /tmp/piptest2.sh:

#!/bin/bash

ROON="/usr/local/Roon"
[ -f ${ROON}/venv/bin/activate ] && source ${ROON}/venv/bin/activate
[[ ":$PATH:" == *":/usr/local/Roon/venv/bin:"* ]] || {
  export PATH=/usr/local/Roon/venv/bin:${PATH}
}
[ -x ${ROON}/venv/bin/python ] && export PYTHON=${ROON}/venv/bin/python

wget -q -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
if [ -f /tmp/get-pip.py ]; then
  ${PYTHON} /tmp/get-pip.py
else
  echo "ERROR: /tmp/get-pip.py not found"
fi

Then run that script as root:

chmod 755 /tmp/piptest2.sh
sudo /tmp/piptest2.sh

OK, I’ll do this right away but I think it’s not related to linux mint.
I just did 2 tests in β€œlive linux” mode on a USB key, same error with xunbuntu and antix. I’m trying to run ubuntu in β€œlive linux”…

For these 2 tests, same error on normal intall … not tried /tmp/piptest.sh

Almost good !

zabodarski@plitvice:/tmp$ chmod 755 /tmp/piptest2.sh
zabodarski@plitvice:/tmp$ sudo /tmp/piptest2.sh
[sudo] Mot de passe de zabodarski :          
Collecting pip
  Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
Collecting setuptools
  Downloading setuptools-69.5.1-py3-none-any.whl.metadata (6.2 kB)
Collecting wheel
  Downloading wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 1.7 MB/s eta 0:00:00
Downloading setuptools-69.5.1-py3-none-any.whl (894 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 894.6/894.6 kB 1.7 MB/s eta 0:00:00
Downloading wheel-0.43.0-py3-none-any.whl (65 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.8/65.8 kB 1.2 MB/s eta 0:00:00
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-24.0 setuptools-69.5.1 wheel-0.43.0

zabodarski@plitvice:/tmp$ sudo /usr/local/Roon/venv/bin/python -m pip install roonapi
Collecting roonapi
  Downloading roonapi-0.1.6-py3-none-any.whl.metadata (2.2 kB)
Collecting ifaddr>=0.1.0 (from roonapi)
  Downloading ifaddr-0.2.0-py3-none-any.whl.metadata (4.9 kB)
Collecting requests>=2.0 (from roonapi)
  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting six>=1.10.0 (from roonapi)
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting websocket_client>=1.4.0 (from roonapi)
  Downloading websocket_client-1.8.0-py3-none-any.whl.metadata (8.0 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.0->roonapi)
  Downloading charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
Collecting idna<4,>=2.5 (from requests>=2.0->roonapi)
  Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.0->roonapi)
  Downloading urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests>=2.0->roonapi)
  Downloading certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Downloading roonapi-0.1.6-py3-none-any.whl (21 kB)
Downloading ifaddr-0.2.0-py3-none-any.whl (12 kB)
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 1.2 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading websocket_client-1.8.0-py3-none-any.whl (58 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.8/58.8 kB 1.2 MB/s eta 0:00:00
Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB 849.2 kB/s eta 0:00:00
Downloading charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.1/142.1 kB 1.4 MB/s eta 0:00:00
Downloading idna-3.7-py3-none-any.whl (66 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.8/66.8 kB 1.4 MB/s eta 0:00:00
Downloading urllib3-2.2.1-py3-none-any.whl (121 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 121.1/121.1 kB 986.2 kB/s eta 0:00:00
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.7 ifaddr-0.2.0 requests-2.31.0 roonapi-0.1.6 six-1.16.0 urllib3-2.2.1 websocket_client-1.8.0

zabodarski@plitvice:/tmp$ /usr/local/Roon/bin/list_zones 
Traceback (most recent call last):
  File "/usr/local/Roon/api/list_zones.py", line 48, in <module>
    roonapi = RoonApi(appinfo, token, server, port)
  File "/usr/local/Roon/venv/lib/python3.10/site-packages/roonapi/roonapi.py", line 798, in __init__
    raise RoonApiException("Host and port of the roon core must be specified!")
roonapi.roonapi.RoonApiException: Host and port of the roon core must be specified!

Your configured zone groupings:
Group_0 = 
Group_1 = 
Group_2 = 
Group_3 = 
Group_4 = 

All that is missing is the configuration of the Roon server.

P.S.: I first did this last test on ubuntu live and I got the same result … I really think it’s not related to linux mint.

dp

Edit1 : Perfect, I managed to modify the /usr/local/Roon/etc/roon_api.ini file and it works perfectly !

Edit2 : Now I have some comments (bugs ?) on this extension… Maybe we should open another topic. That said, very good work !

1 Like

@Dirk-Pitt thank you so much for helping with this! I will rev a new release with an improved pip installation procedure. I’m reticent to point fingers at Mint or anyone other than myself but a distribution that does not include pip in 2024 or install pip as part of a Python virtual environment may possibly deserve someone else’s finger. But, like the Rastas told me, point one finger at someone else and three fingers are pointing back at you.

I would suggest a new thread for issues or open an issue in the repository (I guess Roon tinkerers like having it here - either way is ok with me). Before you start hitting me with issues I would suggest a reinstall from the debian package I will release later today or tomorrow. Your current setup may work but it did not get properly initialized by the package postinstall and may be missing some configuration that process performs.

Good work!

2 Likes

@Dirk-Pitt and all, a new release of RoonCommandLine providing a more robust installation of pip in a Python virtual environment is available. Tis is version 2.1.0 release 6. The debian format installation package is at https://github.com/doctorfree/RoonCommandLine/releases/download/v2.1.0r6/RoonCommandLine_2.1.0-6.deb

The only change in this release is to the postinstall installation script and standalone Linux and macOS installation scripts. For those operating system distributions that have disabled the ensurepip Python module the RoonCommandLine installation now downloads and runs the get-pip.py script. This provides a more robust pip installation and support for additional platforms. If a previous version of RoonCommandLine successfully installed on your system there is no need to upgrade to this release.

I think what is happening here is that recent versions of Ubuntu are forcing a Python virtual environment, disabling the straightforward use of python -m pip install <pkg> and requiring that modules are installed in a virtual environment. Some Ubuntu based distributions have disabled the ensurepip module to avoid users experiencing this bewildering change in behavior. We are in a transition phase with regards the installation of Python modules as some distributions move toward enforcing virtual environments. You may experience some turbulence during this transition as we fly through uncharted territory.

3 Likes

@Ronald_Record

Hello Ronald,
It’s 6:40 a.m. here.
Thank you very much for this new version.
I’ll test this today and let you know.
Good evening, dp.

Hello everyone,
I had fun today.
I tested this latest version with all these environments :

  • antiX-23.1_x64-full.iso
  • debian-12.5.0-amd64-DVD-1.iso
  • linuxmint-21.3-cinnamon-64bit.iso
  • linuxmint-21.3-xfce-64bit.iso
  • MX-23.2_x64.iso
  • ubuntu-24.04-desktop-amd64.iso
  • ubuntustudio-24.04-dvd-amd64.iso
  • xubuntu-24.04-desktop-amd64.iso
  • Zorin-OS-17.1-Core-64-bit-r1.iso

Well I must say that it was a real success !
Well done Ronald and thank you again.
See you soon, dp.

2 Likes

Thanks for creating this amazing extension.

I use Node-RED to control Roon and have been using the roon-extension-mqtt plugin. While it has been working well for me for most commands, it does not properly handle playlists with more than 98 tracks. I installed your plugin on my Node-RED box, and it works great, triggering command-line calls to trigger the Roon actions I need (with no limitations on the playlists).

I am trying to resolve one small issue, which may very well be a Roon API limitation or just an option I am missing.

Much of the time, I want my playlist to be shuffled, and when I do, I use this command:
roon -p "[play_list_name]" -z "[zone_name]" -c "shuffle"

This loads the playlist and shuffles the tracks, though it always starts playing the first track on the playlist (the rest are shuffled).

I work around this by immediately sending this command:
roon -z "[zone_name]" -c "next"

This skips to the next track (which has been shuffled), but this has two drawbacks. First, I can usually hear the first second or so of the first track before Roon responds to the β€œnext” command. The second issue is that the track is now marked as played and will not be shuffled in with the other tracks.

I can work around the second issue by sending another shuffle command, which reshuffles and puts the slipped track back in rotation:
roon -z "[zone_name]" -c "shuffle"

However, I have not found a way to get past the first track starting to play.

So here is my question: In the Roon GUI, when selecting a playlist, there is an option to select β€œshuffle” (if you pull down from the β€œPlay Now” option). This shuffles the playlist before it starts playing. Is there any way to perform the same action from the command line?

Again, thanks for this extension.

@louger thanks for bringing this to my attention. I think this may be something I can address in RoonCommandLine and not a limitation of the Roon API. Right now the order in which the roon command is processing its arguments may be the culprit - it plays the playlist then it enables shuffle. I will experiment with this and see if it is possible to enable shuffle prior to play or just how best to handle this.

@Ronald_Record I think it may be possible to use β€œPlay Shuffled” rather than the default play command, when starting to play the playlist.

Thanks for looking into this.

@GregD @louger Hi Greg! Thanks for the suggestion. I have shuffled playlists working in a test environment using the action keyword Shuffle when calling play_media for a playlist (not Play Shuffled but that pointed me in the right direction).

So I think I have a fix for playing shuffled playlists in a manner that is supported by the Roon API and pyroon. So far I have only made this work for shuffled playlists using a command like the one Lou is using. There are quite a few other areas of code that really should get a similar treatment. However, I do not have the time right now so I will probably release a preliminary fix this weekend after testing is completed and this preliminary fix release will only address Lou’s specific issue.

Hopefully I do not encounter any other issues with this method and we will have shuffled playlists working correctly soon. Thanks Lou and Greg!

1 Like

Glad you got it working - and sorry for the faulty lead!

I considered doing something similar in home assistant - but the default HA command doesn’t have an action parameter and the user who needed found a workround.

That is great news. I will certainly be testing once you have it done. Many thanks.

@louger A new release of RoonCommandLine is available with fixes for shuffled playlist playback. See Release RoonCommandLine Version 2.1.1 Release 1 Β· doctorfree/RoonCommandLine Β· GitHub for release notes and installation asset download.

Let me know if this resolves your issues with shuffled playlist playback or if you encounter any problems.

Thanks for raising this issue and helping to improve RoonCommandLine.

2 Likes

It is working perfectly so far. I will let you know if anything unexpected pops up. Thanks for the very quick response.