Introduction
This section describes the python integration between the Preamplifier and a Volumio2 media player. Some examples of use case:
- Switch on amplifier when media player playback is started
- Set the input to the Raspberry Pi
- Show the song title in the display each time a new song is played
For connecting with Volumio python SocketIO client is used: https://pypi.org/project/socketIO-client/
For connecting to the Preamp python serial is used.
The DjukePreamp python files can be found on on GIT: https://github.com/Djuke-DIYAudio/preamp/tree/master/python
Preparations
Lets login using ssh on Volumio2 (default user=volumio, pw=volumio):
ssh Dit e-mailadres is beschermd tegen spambots. U heeft JavaScript nodig om het te kunnen zien. (replace the ip-address if needed)
The first time after login, update the package database.
sudo apt-get update
Install pip and use pip to install python-SocketIO-client (this will take some time, since many depending packages need to be installed)
sudo apt-get install python-pip
sudo pip install python-SocketIO-client
The connection to the Preamplifier uses python-serial, if it is not already installed, install it with
sudo apt-get install python-serial
Install GIT and checkout the Preamplifier files:
sudo apt-get install git
git checkout https://github.com/Djuke-DIYAudio/preamp.git
Testing
In the python folder, there are two test programs for testing individually the Volumio connection and the Preamp serial connection:
./VolumioClient.py
./PreampClient.py
Example program
A more complete example program with logging is available (DjukePreamp.py), that can be run as a linux service (using DjukePreamp.service). These scripts can be found on the python folder of GIT
To install it as a service, go to the python folder and run:
sudo ./install-as-service.sh
This copies the relevant files to /usr/local/Djuke and runs it as a service when Volumio boots.
DjukePreamp.py is just an example, adjust it to your situation and enjoy!
Troubleshooting
If the example program does not run as expected, the first thing to check is the log information:
less /var/log/DjukePreamp.log
less /var/log/DjukePreamp-serial.log
The first file shows the output of the python script, the second one the serial output. Check for errors or unexpected behaviour there.