Files
hassio-addons/birdnet-pi/README_standalone.md
Alexandre 9b9eab47bc fix(birdnet-pi): make ALSA_CARD actually select the microphone (#2972)
* fix(birdnet-pi): turn ALSA_CARD into a valid ALSA PCM name for REC_CARD

99-run.sh copied ALSA_CARD verbatim into REC_CARD, but BirdNET-Pi passes
REC_CARD to "arecord -D" (scripts/birdnet_recording.sh) and "ffmpeg -f alsa
-i" (scripts/livestream.sh), which expect an ALSA PCM name. A card index such
as ALSA_CARD=1 therefore produced "Unknown PCM 1" and no recording at all.

Build "plughw:CARD=<value>,DEV=0" from a card index or card id, and pass
through a value that already is a PCM name. Also use sed --follow-symlinks so
the rewrite no longer replaces the ~/BirdNET-Pi/birdnet.conf symlink with a
detached copy of /config/birdnet.conf.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix: address CodeRabbit review

* fix(birdnet-pi): bump version so the ALSA_CARD fix actually ships

The PR changed 99-run.sh and added a CHANGELOG entry but left config.yaml
untouched, so `version` still read 2026.08.02. Supervisor only offers a rebuild
when `version` changes: without this the fix would have merged, the add-on would
have kept running the old image, and the issue would have looked closed while
ALSA_CARD stayed broken.

2026.08.15 matches the CHANGELOG heading this PR already adds, which is this
add-on's convention — every past version lines up with a dated heading
(2026.08.02, 2026.07.22, ...). Not a `.N` counter bump: birdnet-pi's `version`
has drifted from updater.json's `upstream_version` (0.11), so the counter rule
does not apply and the add-on's own date scheme governs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(birdnet-pi-zach): turn ALSA_CARD into a valid ALSA PCM name for REC_CARD

birdnet-pi-zach/rootfs/etc/cont-init.d/99-run.sh carried a byte-identical
copy of the same bug fixed in birdnet-pi by this PR: REC_CARD was copied
verbatim from ALSA_CARD, but BirdNET-Pi passes REC_CARD to "arecord -D"
and "ffmpeg -f alsa -i", which expect an ALSA PCM name, not a card index.
sed -i also replaced the $HOME/BirdNET-Pi/birdnet.conf symlink with a
detached copy on first use.

Apply the same fix: build "plughw:CARD=<value>,DEV=0" from a card index
or card id, pass through a value that already is a PCM name, and use
sed --follow-symlinks against /config/birdnet.conf only. Documented in
README_standalone.md, same as birdnet-pi.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix: resolve ALSA_CARD against real PCM names, not a fixed allowlist

CodeRabbit and Codex both flagged that the passthrough check only recognized
default/null/pulse/pipewire: any other colon-free ALSA PCM name (sysdefault,
front, surround51, a custom .asoundrc alias, ...) was still misread as a card
index/id and rewritten as plughw:CARD=<name>,DEV=0, which then fails to open.

alsa-utils is already installed in both images, so check the value against
"arecord -L" (an exact, whole-line match against its unindented PCM-name
lines) instead of hardcoding the set of names ALSA ships with. Anything that
isn't a real PCM name still falls through to the plughw:CARD= build, so a
numeric index or a card id is handled exactly as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 19:22:18 +02:00

151 lines
6.0 KiB
Markdown

# BirdNET-Pi Docker Installation Guide
I maintain this and other Home Assistant add-ons in my free time: keeping up with upstream changes, HA changes, and testing on real hardware takes a lot of time (and some money). I use around 5-10 of my >110 addons so regularly I install test machines (and purchase some test services such as vpn) that I don't use myself to troubleshoot and improve the addons
If this add-on saves you time or makes your setup easier, I would be very grateful for your support!
[![Buy me a coffee][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
[![Donate via PayPal][paypal-badge]](https://www.paypal.com/donate/?hosted_button_id=DZFULJZTP3UQA)
## Addon informations
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
[paypal-badge]: https://img.shields.io/badge/Donate%20via%20PayPal-0070BA?logo=paypal&style=flat&logoColor=white
This guide provides instructions on how to install and run the BirdNET-Pi container using Docker Compose without dependency on HomeAssistant.
_Note : For usage as an HomeAssistant addon, see [here](https://github.com/alexbelgium/hassio-addons/blob/master/birdnet-pi/README.md)_
Thanks to @gotschi for the initial Docker Compose
## Prerequisites
Ensure you have the following installed on your system:
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
## Installation
1. **Create a directory for BirdNET-Pi**
```sh
mkdir -p ~/birdnet-pi && cd ~/birdnet-pi
```
2. **Create a `docker-compose.yml` file**
Create and open the file with:
```sh
nano docker-compose.yml
```
Copy and paste the following configuration:
```yaml
services:
birdnet-pi:
container_name: birdnet-pi
image: ghcr.io/alexbelgium/birdnet-pi-amd64:latest # or ghcr.io/alexbelgium/birdnet-pi-aarch64:latest depending on your system
restart: unless-stopped
ports:
- "8001:8081" # Used to access WebUI
- "80:80" # Optional: set to 80 to use Caddy's automatic SSL. Can otherwise be set to null to avoid opening an additional port
environment:
- TZ=Europe/Vienna # Optional: Set your timezone according to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- BIRDSONGS_FOLDER=/config/BirdSongs # Folder to store bird songs, be sure to use a path that is mapped to a volume (such as /config)
- LIVESTREAM_BOOT_ENABLED=false # Enable/disable livestream on boot
- Use_tphakala_model_v2=false # Switch to BirdNET-Go classifier files
- ssl=false # Enable/disable SSL
- certfile=fullchain.pem # SSL certificate file (located in /ssl/)
- keyfile=privkey.pem # SSL key file (located in /ssl/)
- pi_password= # Optional: Set web terminal password for user `pi`
- MQTT_HOST_manual= # Optional: Manual MQTT host
- MQTT_PASSWORD_manual= # Optional: Manual MQTT password
- MQTT_PORT_manual= # Optional: Manual MQTT port
- MQTT_USER_manual= # Optional: Manual MQTT user
- PULSE_SERVER=unix:/tmp/pulseaudio.socket
- PULSE_COOKIE=/tmp/pulseaudio.cookie
volumes:
- ./config:/config # All your configuration files - and location of the default Birdsongs folder
- ./ssl:/ssl # SSL certificates
- /dev/shm:/dev/shm # Shared memory
- /tmp/pulseaudio.socket:/tmp/pulseaudio.socket
- /tmp/pulseaudio.client.conf:/etc/pulse/client.conf
devices:
- /dev/snd:/dev/snd
group_add:
- audio
tmpfs:
- /tmp # Optional
```
3. **Start the Container**
Run the following command in the same directory as `docker-compose.yml`:
```sh
docker compose up -d
```
This will start the BirdNET-Pi container in detached mode.
4. **Access BirdNET-Pi Web UI**
Open your browser and navigate to:
```sh
http://localhost:8001 # Or whatever port you have configured
```
Replace `localhost` with your server's IP address if running on another machine.
When prompted for credentials in the web terminal, use the username `pi` and the password defined by `pi_password` (blank if unset).
## troubleshoot
If rtsp feed doesn't work, perhaps you need to add "-rtsp-transport tcp" to your ffmpeg instruction, or allow udp on your network
### Selecting the microphone
By default the container records through PulseAudio (`REC_CARD=default` in `birdnet.conf`). To record directly from a USB microphone instead, find it on the host with `arecord -l`, then pass its card number (or its card id) as `ALSA_CARD`:
```yaml
environment:
- ALSA_CARD=1 # "card 1: Audio [KT USB Audio]" in the output of "arecord -l"
```
At startup this writes `REC_CARD=plughw:CARD=1,DEV=0` into your `birdnet.conf`. A value that already is a full ALSA PCM name, as listed by `arecord -L`, is used as provided - for example `ALSA_CARD=dsnoop:CARD=Audio,DEV=0`, which allows the recording and the livestream services to read the same microphone at the same time.
## Updating to the Latest Version
To check for new versions of the container and update:
1. **Check for the latest version**
Visit the container registry:
[https://github.com/alexbelgium/hassio-addons/pkgs/container/birdnet-pi-amd64](https://github.com/alexbelgium/hassio-addons/pkgs/container/birdnet-pi-amd64)
The latest version tag (e.g., `2025.02.23`) will be listed.
2. **Update and restart the container**
Run the following commands:
```sh
docker compose pull birdnet-pi
docker compose up -d --force-recreate
```
This pulls the latest image and restarts the container.
3. **Verify the update**
```sh
docker images | grep birdnet-pi
```
This will show the latest downloaded image version.
## Stopping and Removing the Container
To stop and remove the container, run:
```sh
docker compose down
```
This will stop and remove BirdNET-Pi while keeping the configuration and recorded songs intact.
---
Now you're all set to enjoy BirdNET-Pi with Docker! 🐦