qbee-gpio
A python script to control an LCD and amplifier relay for use in an AirPlay and/or Spotify Connect Raspberry Pi server.
- Detect sound ouput and turn on the amplifier power supply.
- Get the track information and display it on an LCD.
- Auto turn off amplifier power supply and/or shutdown after set period of inactivity.
Installation
sudo python -m pip install qbee-gpio
For first time usage:
qbee --init-config
then change what you need in ~/.qbee.yaml.
Usage
qbee
Pass a -v flag for verbose logging.
Detailed setup
Qbee
For starting up automatically, create /etc/systemd/system/qbee.service file with (adjust users/paths):
[Unit]
Description=Qbee
After=network-online.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
User=qbee
Group=qbee
ExecStart=/usr/local/bin/qbee
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Enable to run on boot: sudo systemctl enable qbee --now.
Optionally, specify a CONFIG env variable when running the script:
CONFIG="/etc/qbee.yaml" ~/.local/bin/qbee ....
The default config will be located at ~/.qbee.yaml.
Setting up shairport-sync
You can follow instructions here. Here is what I used.
Install required packages:
sudo apt install --no-install-recommends build-essential git autoconf automake libtool \
libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
Install shairport-sync:
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-metadata
make
make install
cd ../ && rm -rf shairport-sync
Edit /etc/shairport-sync.conf file, uncomment the metadata block to enable:
metadata =
{
enabled = "yes";
include_cover_art = "no";
pipe_name = "/tmp/shairport-sync-metadata";
pipe_timeout = 5000;
};
Enable to run on boot: sudo systemctl enable shairport-sync --now.
Setting up Librespot
If Raspotify is available on your system, use it, otherwise, you will need to compile librespot.
For starting up automatically, create /lib/systemd/system/librespot.service file with (adjust users/paths):
[Unit]
Description=Librespot
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target
[Service]
User=qbee
Group=qbee
EnvironmentFile=/etc/librespot.env
ExecStart=/usr/bin/librespot
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
The conf /etc/librespot.env should look like:
LIBRESPOT_NAME="Qbee"
LIBRESPOT_QUIET=
LIBRESPOT_ENABLE_VOLUME_NORMALISATION=
LIBRESPOT_BITRATE="320"
LIBRESPOT_BACKEND="alsa"
LIBRESPOT_INITIAL_VOLUME="40"
LIBRESPOT_ONEVENT="/usr/local/bin/librespot-pipe.sh"
QBEE_LIBRESPOT_METADATA_PIPE="/tmp/librespot-metadata"
You will also need to set up the script to pipe events to Qbee in /usr/local/bin/librespot-pipe.sh and make it executable:
#!/usr/bin/bash
# Expose track_changed librespot events in a named pipe.
# Only expose track changed events.
if [ "$PLAYER_EVENT" != 'track_changed' ]; then
exit 0
fi
# Need a named pipe.
if [ "$QBEE_LIBRESPOT_METADATA_PIPE" == '' ]; then
exit 0
fi
# It must already be opened for reading.
if ! [ -p "$QBEE_LIBRESPOT_METADATA_PIPE" ] ; then
exit 0
fi
artist=$(printf '%s' "$ARTISTS" | base64)
album=$(printf '%s' "$ALBUM" | base64)
title=$(printf '%s' "$NAME" | base64)
printf 'artist:%s,album:%s,title:%s\t' "$artist" "$album" "$title" > "$QBEE_LIBRESPOT_METADATA_PIPE"
Setting up Hifiberry DAC
Edit /boot/config.txt to add:
dtparam=audio=on
dtoverlay=hifiberry-dac
To disable the built-in sound card, edit /etc/modprobe.d/raspi-blacklist.conf to add:
blacklist snd_bcm2835
Edit /etc/asound.conf to set the default sound card for alsa, add:
defaults.pcm.card 0
defaults.ctl.card 0
Disable Pi GPU
This should help give more power to the CPU, useful for older Pis.
Edit /boot/config.txt and add:
gpu_mem=16
disable_l2cache=0 # For pi 1 only
gpu_freq=250
Full circuit diagram
The relay turns on the 24 VDC power supply, which powers the amplifier, the LCD backlight and a green status LED.
Metadata
Release files for qbee-gpio 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qbee_gpio-2.0.1.tar.gz | 13.3 kB | Without provenance | Details for qbee_gpio-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qbee_gpio-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for qbee_gpio-2.0.1-py3-none-any.whl |
Total release size: 29.4 kB
Release files / qbee_gpio-2.0.1.tar.gz
| Download URL | qbee_gpio-2.0.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffcf1824b75d32c6017174d4844f780d7a0a8cb00b365050e00b1102d022dfe3
|
|
BLAKE2b-256 checksum How to use checksums |
c50ae4c2e5c04a9603b044670f190b8eadcd95b59353bfc092a7bc7884d96e08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
|
Release files / qbee_gpio-2.0.1-py3-none-any.whl
| Download URL | qbee_gpio-2.0.1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0de8089584071ced9347f92d55ce1914991b2605de31c13bdcda05a11784c374
|
|
BLAKE2b-256 checksum How to use checksums |
426128eea15308fafd9537969fc79a6df57e5763b52378f21af5649d650aa028
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
|
Security for qbee-gpio 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.