[Plugin] pirate audio

I created a PR [PIRATEAUDIO] switch to use python-socketio by tarioch · Pull Request #325 · volumio/volumio-plugins-sources · GitHub if someone can test this it would be great as I’m not using the plugin as is.

@tario Sorry for the noob question but how can I test that ? Is there some command line to enter by ssh on the volumio setup ?

Probably something like this should work, ssh onto the device and then do

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/22edd204325ff0befe908dcef9111ec5882901ea/pirateaudio/display.py

@tario It worked ! :grin:

I cant get to it today or tomorrow but should be able to test this over the weekend.

@tario do I understand you modified the plugin to call for the older version of the socketio library?

I quickly looked it up and it appears this library had not been updated for a long time?? Why the change?

@SimpleSmarts I just noticed that the release notes Volumio Changelog contain this

Update socket.io to 2.3.0

And looking at the original library (socketIO-client) which was used, wasn’t upgraded since 2016, I guessed there might have been a change in the protocol. That’s how I then found the “new” library (python-socketio) which is maintained. First test didn’t work, but then I saw a table on that new library which indicated which version of the library to use with which version of the javascript part, as volumio uses 2.3.0 (don’t ask my why they use an old, outdated version of this), I used the matching version.

1 Like

Thanks very much @tario for looking into this and providing an excellent solution! This worked for me, however the patched file throws an error for me on startup every time which relates to:

    File "/data/plugins/miscellanea/pirateaudio/display.py", line 139, in connect
    SOCKETIO.emit('getState', '', on_push_state)
NameError: name 'on_push_state' is not defined

Which I think is trying to get the volumio state at pirateaudio startup. As a result, the screen is blank to start. When I subsequently press pause then play, it updates the display correctly, I’m not an expert on why on_push_state is not accessible here, is this something that is fixable?

Fixed, just get the new file from https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f667de7567e9b9ad03c72cfb3bf5411b8b387e59/pirateaudio/display.py

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f667de7567e9b9ad03c72cfb3bf5411b8b387e59/pirateaudio/display.py
1 Like

Big thanks for the explanation. I’m a harware guy, I can test and get around a bit of code so this help learning.
I just noticed now you moved to a different, maintained lib python-socketio, great.

Is the pirate-audio plugin maintained? I saw your PR on Github.

I will test this weekend.

What a star, that’s great! Cheers @tario

I’ve found some more problems in the Options-Menue (upper right button) with display.py -
patch.txt (1.2 KB)

  • choosing sources did not work
  • choosing next/previous did not work

I got that fixed by applying following patch (attached) to your file:

--- display.py.orig	2024-06-07 18:19:07.000000000 +0200
+++ display.py	2024-06-07 18:23:18.000000000 +0200
@@ -607,14 +607,14 @@
             return
         #elif NAV_ARRAY_TYPE[NAV_DICT['MARKER']] == 'prevnext':  # v.0.0.4
         if NAV_ARRAY_TYPE[NAV_DICT['MARKER']] == 'prevnext':  # v.0.0.4
-            SOCKETIO.emit('getQueue', on_push_queue)  # refresh variables of queue
+            SOCKETIO.emit('getQueue', callback=on_push_queue)  # refresh variables of queue
             VOLUMIO_DICT['MODE'] = 'prevnext'  # optimieren wg. global bzw. wird das überhaupt benötigt
             display_stuff(IMAGE_DICT['BG_DEFAULT'], [''.join([str(VOLUMIO_DICT['POSITION'] + 1), '/', str(LEN_QUEUE)]), OBJ_TRANS['DISPLAY']['PREVNEXT'], TITLE_QUEUE[VOLUMIO_DICT['POSITION']]], 1, 0, 'seek')
             return
         # only get called if no return before was executed
         #else:  # browsesource
         reset_variable('navigation')
-        SOCKETIO.emit('getBrowseSources', '', on_push_browsesources)
+        SOCKETIO.emit('getBrowseSources', callback=on_push_browsesources)
     #else:
     if mode not in ['player', 'navigation', 'menu']:
         reset_variable('player')


Thank you, updated (don’t need to have those handlers as they are already globally registered)

https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f0b67728aec403a6be8d395ee9de2b77d7a0518e/pirateaudio/display.py

sudo pip3 install "python-socketio>=4,<5"
cd /data/plugins/system_hardware/pirateaudio
mv display.py display.py.bak
wget https://raw.githubusercontent.com/volumio/volumio-plugins-sources/f0b67728aec403a6be8d395ee9de2b77d7a0518e/pirateaudio/display.py
1 Like

Thank you, updated (don’t need to have those handlers as they are already globally registered)

Aaah. That makes sense.I’m not that used to python to be honest :slight_smile:

I have run this script to update the display.py file on my Pi3 running volumio 3.695 and it works. :grinning:

You have to enable SSH via the GUI at volumio.local/dev to be able to connect to your pi

hello!
the plugin is now updated to v0.1.2
To be used with volumio => v3.695
no new feature!
:wink:

3 Likes

Been trying to make this work for 3 days. Have a Zero w with pirateaudio headphone. Just tried a fresh image, 3.703 (only one offered) and plugin 0.01.2. No audio, and no screen or buttons. Prior to this I had audio, blank (dark), and no buttons. Please help.
Thanks in advance, Karl

1 Like

Tried with 3.703 and 3.735 with a zero 2W. Have audio, dark screen, and no action fro buttons.
On power, backlight is momentarily on, the goes dark. On shutdown, backlight goes back on. Well into a week of reading this thread, and experimenting without success. Even tried to download an older ver 3.631 and it immediately started upgrading on power-up. Any help would be greatly appreciated!

Are you sure you are not having an issue withthe hardware, Pi or Pirateaudio? I have not used mine for a while and did not try to reinstall since I applythepatch for the community user. I think he did make further chnages afterwards and not sure if it was added to the general release.

It’s only a week since using the Pimoroni-Mopidy with this hardware, working at that time. Tried both a Zero w and a 2w.

Pi Zero 2WH, New Version of PirateAudio-Hat (the one you have to change the pin for the y-button) with Headphone-Jack

Tried with a fresh install of volumio (3.703-2024-06-04-pi) and the latest version of the pirateaudio-plugin (0.1.2) -
you’re right, does not work.

→ ssh onto device, when trying to start the display.py directly I ran into following error :

volumio@volumiotest:/data/plugins/system_hardware/pirateaudio$ python3 display.py 
Traceback (most recent call last):
  File "display.py", line 13, in <module>
    import ST7789  # v0.0.6
ModuleNotFoundError: No module named 'ST7789'

when trying to install ST7789 I ran into a depency problem :

volumio@volumiotest:/data/plugins/system_hardware/pirateaudio$ sudo pip3 install st7789
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting st7789
  Using cached https://files.pythonhosted.org/packages/e3/dd/4fe563f2a757425a3460eee92f9a19ba893ed90f9d85f1be3d7dc91df305/st7789-1.0.1-py3-none-any.whl
Collecting numpy>=1.26.4 (from st7789)
  Could not find a version that satisfies the requirement numpy>=1.26.4 (from st7789) (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6)
No matching distribution found for numpy>=1.26.4 (from st7789)

Crosschecked with my currently working device (which was updated via online updates) and has the lastest plugin installed, I found following versions of st7789 (0.0.4) and numpy (1.16.2) - so I installed them and additionally installed python-socketio >=4 and < 5

sudo pip3 install numpy==1.16.2 
sudo pip3 install st7789==0.0.4
sudo pip3 install "python-socketio>=4,<5"

and tried starting the script again:
volumio@volumiotest:/data/plugins/system_hardware/pirateaudio$ python3 display.py

made sure plugin has a configuration (press configure, and save), enabled it and rebooted the device.

– works.

seems there is a dependency problem… but I’m not an expert nor very used to the volumio infrastructure, so we might have to ask the volumio-maintainers (maybe @balbuze or @tario are the ones to ask?) for help. from my oppinion we would need to install specified versions of these libraries in the plugins install.sh script…or port the plugin to be able to work with higher versions of st7789 (breaks as soon you upgrade from version 0.0.4 to 1.0.0)

# Install the required packages via apt-get, install new python 3.x depencies
echo "Installing new python 3.x and pip3 dependencies for pirateaudio plugin"
sudo apt-get update
sudo apt-get install -y python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
sudo pip3 install st7789 "python-socketio>=4,<5"

Hope that helps you get it working :crossed_fingers: