Roon Command Line Control version 2

We have lift off!

I tried the first suggestion and we found that running pip3 show roonapi just gave an error showing the package couldn’t be found:

image

So next I tried running in a login shell as you suggested - it works!

Feeling a bit brave, I modified this command to:

bash -l -c "roon -c playpause -z Brooklyn"

And lo and behold, it still works :grinning: :grinning:

I’ve tried it with various other options, playlists, live radio, starting/stopping - so far it all works!

You sir are a genius :ok_hand: :ok_hand:

I’ve managed to use Siri on my iMac to run the shortcuts so just need to play around getting them working from HomePods and my watch now…

2 Likes

@Etk Excellent! I wish I knew why a login shell is needed for SSH Shortcuts in this scenario. Something in the shell startup files (e.g. .bashrc, .bash_profile, or .zshrc, etc) must be setting something required for Python.

But, success is success and there’s nothing like it :slight_smile:

Thanks for hanging in there with me.

2 Likes

If you come up with any ideas you want to test on those theories just give me a shout - happy to try things out till you pin down the issue :+1:

ETA - if anyone else is using this solution, if you need to use quotes (for an album name with a space for example), just use single quotes within the main string:

bash -l -c “roon -r ‘BBC 6Music’ -z Brooklyn”

I spent most of this afternoon trying to get Roon Command Line working with AppleScript, and totally failed until I got to these last few comments. I had exactly the same problem as @Etk - a command would work in terminal, but not in AppleScript. Using ‘bash -l -c …’ etc fixed it.

I haven’t tested any other commands other than playpause (which also works), but I assume this format will work for all of them.

Also, if anyone needs to nest commands a bit further than just using single and double quotes, you can also use backticks as follows:

do shell script "bash -l -c 'roon -c stop -z `Kef LSX`'"
1 Like

UPDATE: RoonCommandLine Version 2.0.4 Release 3 now available. Below is a brief description of changes in the recent releases as well as download and installation instructions.

RoonCommandLine version 2.0.4 release 3 is a feature modification release.

This release changes the mute/unmute commands to a toggle. Both commands operate exactly the same, toggling the muting/unmuting of the selected zone or zone grouping. The two commands are retained rather than removing unmute in order to preserve compatibility with any existing scripts that use these commands.

RoonCommandLine version 2.0.4 release 2 is a bugfix release.

This release fixes a bug with muting/unmuting ungrouped zones.

RoonCommandLine version 2.0.4 release 1 adds zone and zone grouping volume control.

The command `roon -v volume` sets the volume level in the selected zone.

The `volume` argument has the format `[g:][r:][s:]num`

Where `g` indicates set volume for all zones in the group
      `r` specifies use relative method volume setting
      `s` specifies use relative_step method volume setting
      `num` can be absolute (0-100) or relative (negative or positive)

RoonCommandLine version 2.0.3 release 2 adds several new commands including support for playing a specified track by artist, playing a specified album by artist, playing either a specified artist or album in designated genre, playing a specified composer, and additional listing options. Listing and playing commands now include support for artist and album name exclusion strings allowing searches for a specified artist/album/composer/genre/playlist whose name includes a specified string but not another string. This exclusion filtering enables narrower listing, searching, and playing of library media.

Checks for Python 3 and Pip have been added to pre-installation scripts, MacOS installation has been significantly improved, installation of the roonapi Pip module is handled more gracefully.

RoonCommandLine version 2.0.x releases add support for detection of the Roon Core port as well as its IP address. The port number is stored in roon_api.ini and used in all subsequent calls to the Python Roon API. This was necessary as Roon Labs changed the port number in the most recent update. Extensions shouldn’t be assuming a hard coded port number anyway so this change prompted a good improvement although it was irritating at first. A bug introduced by the change to return status of the Bash builtin type command was addressed. RoonCommandLine commands’ location are added to PATH or full path used in SSH invocations. The installation script has been revised to work with the updated Python roonapi module version numbering. SSH invocations should work in a wider range of environments with this release.

The installation automatically detects and stores the Roon Core IP and port. There is no need for any manual configuration.

IMPORTANT NOTE Older versions of RoonCommandLine will no longer function properly. In order to use RoonCommandLine you must install version 2.0.2 release 1 or later.

Download the latest Debian or RPM package format release

Install the package on Debian based systems by executing the command

sudo apt install ./RoonCommandLine_2.0.4-3.deb

Install the package on RPM based systems by executing the command

sudo yum localinstall ./RoonCommandLine-2.0.4-3.rpm

Removal of the package on Debian based systems can be accomplished by issuing the command:

sudo apt remove rooncommandline

Removal of the package on RPM based systems can be accomplished by issuing the command:

sudo yum remove RoonCommandLine

To install on Mac OS X, clone the repository and execute the Install command:

git clone https://gitlab.com/doctorfree/RoonCommandLine.git
cd RoonCommandLine
./Install
1 Like

Hmmm. I can’t get this to install. Is there an option for people not on Debian or Fedora based distros? Pip worked fine to install the API. When I try to do a manual install it seems to want an RPM.

git clone https://github.com/doctorfree/RoonCommandLine

cd RoonCommandLine

./Install

and I get
RoonCommandLine_2.0.5-1.rpm not found.

Looking at the .Install file it seems it’s just checking for a .deb or .rpm to install if I’m reading it right. I don’t see an easy way to build this from source, but I’m certainly no programmer.

Any advice appreciated.

@Bob_Smith1 , I’d be happy to look into providing either a packaged solution for your platform or a scripted install as I did for Macs. Can you provide me with system information on your operating system? There are so many Linux distributions with so many packaging formats, I picked the two distributions I run at home. These two use RPM and Debian format packaging which covers the majority of Linux users. I would like to provide packages for other platforms as well. But I may occasionally need some info from you. Like platform info. This can usually be retrieved in one of several ways:

uname -a
hostnamectl
cat /etc/*-release

Any information on your platform and standard packaging would be appreciated. Thanks.

If you’re considering other distributions, may I add Arch (Arch User Repository) to your list?

https://wiki.archlinux.org/title/Creating_packages

# uname -a
Linux roon 5.17.3-arch1-1 #1 SMP PREEMPT Thu, 14 Apr 2022 01:18:36 +0000 x86_64 GNU/Linux
# hostnamectl
 Static hostname: roon
       Icon name: computer-desktop
         Chassis: desktop 🖥
      Machine ID: <id>
         Boot ID: <id>
Operating System: Arch Linux                      
          Kernel: Linux 5.17.3-arch1-1
    Architecture: x86-64
 Hardware Vendor: Intel_R_ Client Systems
  Hardware Model: NUC8i5BEH
# cat /etc/*-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux-logo
1 Like

@Scott_Jann , I will try and find time to learn Arch Linux packaging but I do not currently have an Arch Linux system on which to test. I modified the Install script and added a linInstall script which performs a scripted install if no packaging is found. I have not yet tested this on Arch Linux so it’s still in development but it is currently available in the RoonCommandLine repository. A git pull should get you a linInstall and updated Install script. If you feel courageous, try ./Install on Arch Linux and let me know how it goes. ./Uninstall should remove any previous installation.

I’m on Garuda Linux, so also Arch-based. I don’t know anything about packaging things for AUR, but I don’t believe it’s too hard. Happy to help in any way I can, though that’s pretty limited.

The new script worked just fine for me.

It would be nice to have a command to display the currently playing song.

Also there’s a typo in the help file. It lists

roon -i -z 'Mac Pro DAC'

As the command for both “Get info on all Roon zones” and "Get extended info on Roon zone named ‘Mac Pro DAC’ ". I believe the first one should just be roon -i, right?

Great work, will be fun the mess with.

1 Like

@Bob_Smith1 , I corrected the typo and pushed that to the repo. I would also like to display the currently playing song but I do not see how to do that with the API. It’s a good suggestion. I will keep looking for a way to implement this.

I know NOTHING about APIs or coding. So forgive me if I’m getting this totally wrong. But looking at JSDoc: Class: Zone isn’t now_playing and then the one, two, or three_line what we’re after?

2 Likes

@Bob_Smith1 , this is why it’s always good to have another pair of eyes around. Thanks! I’ve got “Now playing” working using the Zone properties you found. I’ll test and publish this in the next few days.

1 Like

Thanks for this code! I have one question: what is the difference between stop and pause? In the roon app there is no stop button only pause. If I use the API’s stop command the playing item is paused. I would like to have a real stop function possibly with clearing all the upcoming items in the queue.

There isn’t a button, but the command is there:

That said, I don’t know how this is difference to Play/Pause.

@Gyorgy_Rath @DaveN the API doc indicates that stop not only stops playback but releases the audio device. See JSDoc: Class: RoonApiTransport

1 Like

@Gyorgy_Rath , currently RoonCommandLine doesn’t do any queue management. I don’t know if the API supports that but I will consider it going forward. It would be nice to manage the queue from the command line.

1 Like

This morning roon command line was not working fine. When switching on any zone, the first zone in my Roon environment started playing. For some reason pyroonconf was corrupted. It showed an extra line without matching quotes in the 2nd line as below. I’ve manually removed the 2nd line and afterwards roon command line was functioning fine again. I could not find a cause for pyroonconf getting corrupted.

My /usr/local/Roon/etc/pyroonconf:

LOCAL=true
r Bose"
ROON_ZONE="Woonkamer Bose"

@Ron_Witkamp thanks for reporting this. I’ll look into possible causes but it sure looks weird. Did you have any unusual interruptions on the system where RoonCommandLine is running? Off the top of my head I do not know why something like this would happen but I will comb through the pyroonconf handling to look for possible culprits.

That’s what I was thinking also. Power outage? SD card errors? (it’s running on a Raspberry!)

I could not find any external cause nor something strage in the errorlogs.