birdnet-go: invert MQTT/MariaDB auto-config to opt-in

Replace mqtt_disable / mariadb_disable (opt-out, default-on) with
mqtt_auto_config / mariadb_auto_config (opt-in, default-off). When the
HA addon is detected but the option is off, still log the broker /
database credentials and a hint pointing the user at the option — so
discoverability stays the same without surprise config rewrites.
This commit is contained in:
Claude
2026-05-28 17:21:12 +00:00
parent 2087da7f18
commit 854f90cbe8
5 changed files with 54 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
## nightly-20260525-3 (28-05-2026)
- Auto-configure the Home Assistant MQTT addon: when Mosquitto is active, `realtime.mqtt.{enabled,broker,username,password}` are written directly to `config.yaml`. Set the new `mqtt_disable: true` addon option to opt out.
- Auto-configure the Home Assistant MariaDB addon: when active, `output.mysql.*` is filled in and `output.sqlite.enabled` is set to `false`. Set the new `mariadb_disable: true` addon option to opt out.
- New `mqtt_auto_config` addon option (default `false`). When `true` and the Home Assistant MQTT addon is active, `realtime.mqtt.{enabled,broker,username,password}` are written directly to `config.yaml` on every restart. When `false` but Mosquitto is detected, the addon still logs the broker details and reminds you about the option — nothing is written.
- New `mariadb_auto_config` addon option (default `false`). When `true` and the Home Assistant MariaDB addon is active, `output.mysql.*` is filled in and `output.sqlite.enabled` is set to `false`. When `false` but MariaDB is detected, the addon logs the credentials and reminds you about the option.
- **Breaking**: `output.sqlite.path` and `logging.file_output.*` are now seeded only when missing from `config.yaml` (previously overwritten every restart). Values changed through the BirdNET-Go UI or by hand-editing `config.yaml` now survive container restarts. If you relied on `LOG_MAX_SIZE_MB` / `LOG_MAX_AGE_DAYS` addon options to override an existing setting in `config.yaml`, remove the existing key from `config.yaml` or edit it directly — the option will only be applied on first run.
- **Breaking (UI only)**: The nginx ingress reverse-proxy no longer rewrites HTML `href`/`src`/`action` attributes; upstream BirdNET-Go handles those itself via `X-Ingress-Path`. JavaScript string-literal rewrites are unchanged. Please file an issue if you see broken images, links, or forms in the ingress UI after upgrade.
- Fix database-migration restore: the timestamped backup created during a `BIRDSONGS_FOLDER` change was being written to the script's working directory and looked up under a fresh timestamp on restore, so a SQL failure left the user unable to recover. Backup path is now absolute and reused for restore.

View File

@@ -49,8 +49,8 @@ Options can be configured through three ways :
ALSA_CARD : number of the card (0 or 1 usually), see https://github.com/tphakala/birdnet-go/blob/main/doc/installation.md#deciding-alsa_card-value
TZ: Etc/UTC specify a timezone to use, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
COMMAND : realtime --rtsp url # allows to provide arguments to birdnet-go
mqtt_disable: false # set true to skip auto-wiring of the Home Assistant MQTT addon
mariadb_disable: false # set true to skip auto-wiring of the Home Assistant MariaDB addon
mqtt_auto_config: false # set true to auto-wire the Home Assistant MQTT addon into config.yaml
mariadb_auto_config: false # set true to auto-wire the Home Assistant MariaDB addon into config.yaml (also disables SQLite)
```
- Config.yaml
@@ -59,11 +59,11 @@ Additional variables can be configured using the config.yaml file found in /conf
- Config_env.yaml
Additional environment variables can be configured there
### MQTT and MariaDB auto-configuration
### MQTT and MariaDB auto-configuration (opt-in)
If the Home Assistant **MQTT** addon is installed and running, BirdNET-Go is now wired to it automatically on startup: `realtime.mqtt.enabled`, `broker`, `username`, and `password` in `config.yaml` are populated from the HA Mosquitto credentials, and the topic defaults to `birdnet`. Set `mqtt_disable: true` in the addon options to keep manual control.
If the Home Assistant **MQTT** addon is installed and running and you set `mqtt_auto_config: true` in the addon options, the addon writes the HA Mosquitto credentials directly into BirdNET-Go's `config.yaml` on every startup: `realtime.mqtt.enabled`, `broker`, `username`, and `password` are populated, and the topic defaults to `birdnet`. When the option is `false` (the default), the addon still logs the broker details and reminds you about the option whenever Mosquitto is detected — nothing is written.
If the Home Assistant **MariaDB** addon is installed and running, BirdNET-Go is switched to it automatically: `output.mysql` is enabled with the HA credentials (database `birdnet`, created on first connect) and `output.sqlite.enabled` is set to `false`. Set `mariadb_disable: true` to keep using SQLite or to point at a different MySQL server manually.
If the Home Assistant **MariaDB** addon is installed and running and you set `mariadb_auto_config: true`, the addon writes the HA credentials into `output.mysql.*` and sets `output.sqlite.enabled` to `false` (database name `birdnet`, created on first connect). When the option is `false` (the default), the addon only logs the credentials so you can configure them manually.
The addon also seeds `output.sqlite.path` and `logging.file_output.*` defaults only when those keys are missing from `config.yaml`, so values you change through the BirdNET-Go UI now survive container restarts.

View File

@@ -89,8 +89,8 @@ options:
LOG_MAX_SIZE_MB: 50
LOG_MAX_AGE_DAYS: 7
homeassistant_microphone: false
mqtt_disable: false
mariadb_disable: false
mqtt_auto_config: false
mariadb_auto_config: false
panel_admin: false
panel_icon: mdi:bird
ports:
@@ -116,8 +116,8 @@ schema:
cifsusername: str?
homeassistant_microphone: bool?
localdisks: str?
mariadb_disable: bool?
mqtt_disable: bool?
mariadb_auto_config: bool?
mqtt_auto_config: bool?
networkdisks: str?
services:
- mysql:want

View File

@@ -2,10 +2,12 @@
# shellcheck shell=bash
set -e
# If the Home Assistant MariaDB addon is active, wire its credentials directly
# into BirdNET-Go's config.yaml. Upstream reads MySQL settings only from YAML
# (no env-var overrides exist). Users who prefer SQLite or a different MySQL
# server can set mariadb_disable: true in the addon options.
# When the Home Assistant MariaDB addon is active, optionally wire its
# credentials directly into BirdNET-Go's config.yaml. Upstream reads MySQL
# settings only from YAML (no env-var overrides exist), so this is the only
# way to auto-configure them. The behaviour is opt-in via the
# mariadb_auto_config addon option. When the option is off but MariaDB is
# detected, we log a one-shot hint pointing users at the option.
CONFIG_LOCATION="/config/config.yaml"
MYSQL_DATABASE="birdnet"
@@ -14,8 +16,20 @@ if ! bashio::services.available 'mysql'; then
exit 0
fi
if bashio::config.true 'mariadb_disable'; then
bashio::log.info "MariaDB auto-configuration disabled by 'mariadb_disable' addon option; skipping."
MYSQL_HOST="$(bashio::services 'mysql' 'host')"
MYSQL_PORT="$(bashio::services 'mysql' 'port')"
MYSQL_USER="$(bashio::services 'mysql' 'username')"
MYSQL_PASS="$(bashio::services 'mysql' 'password')"
if ! bashio::config.true 'mariadb_auto_config'; then
bashio::log.green "---"
bashio::log.yellow "Home Assistant MariaDB addon detected. Set 'mariadb_auto_config: true' in the addon options to wire it into BirdNET-Go automatically (and disable SQLite). Connection details:"
bashio::log.blue "Database user : ${MYSQL_USER}"
bashio::log.blue "Database password: ${MYSQL_PASS}"
bashio::log.blue "Database name : ${MYSQL_DATABASE}"
bashio::log.blue "Host-name : ${MYSQL_HOST}"
bashio::log.blue "Port : ${MYSQL_PORT}"
bashio::log.green "---"
exit 0
fi
@@ -24,17 +38,11 @@ if [ ! -f "$CONFIG_LOCATION" ]; then
exit 0
fi
MYSQL_HOST="$(bashio::services 'mysql' 'host')"
MYSQL_PORT="$(bashio::services 'mysql' 'port')"
MYSQL_USER="$(bashio::services 'mysql' 'username')"
MYSQL_PASS="$(bashio::services 'mysql' 'password')"
bashio::log.green "---"
bashio::log.blue "Home Assistant MariaDB addon detected; auto-configuring BirdNET-Go"
bashio::log.blue "mariadb_auto_config enabled; writing Home Assistant MariaDB credentials into BirdNET-Go config and disabling SQLite"
bashio::log.blue "Host: ${MYSQL_HOST}:${MYSQL_PORT}"
bashio::log.blue "User: ${MYSQL_USER}"
bashio::log.blue "Database: ${MYSQL_DATABASE} (will be created by BirdNET-Go on first connect)"
bashio::log.blue "(Set 'mariadb_disable: true' in addon options to opt out)"
bashio::log.green "---"
# Upstream config.go stores port as a string; pass it as such to match.

View File

@@ -2,10 +2,12 @@
# shellcheck shell=bash
set -e
# If the Home Assistant MQTT addon is active, wire its credentials directly
# into BirdNET-Go's config.yaml (upstream reads MQTT settings only from YAML;
# no env-var overrides exist). Users who prefer to manage MQTT manually can
# set mqtt_disable: true in the addon options.
# When the Home Assistant MQTT addon is active, optionally wire its
# credentials directly into BirdNET-Go's config.yaml. Upstream reads MQTT
# settings only from YAML (no env-var overrides exist), so this is the only
# way to auto-configure them. The behaviour is opt-in via the
# mqtt_auto_config addon option. When the option is off but Mosquitto is
# detected, we log a one-shot hint pointing users at the option.
CONFIG_LOCATION="/config/config.yaml"
@@ -13,27 +15,31 @@ if ! bashio::services.available 'mqtt'; then
exit 0
fi
if bashio::config.true 'mqtt_disable'; then
bashio::log.info "MQTT auto-configuration disabled by 'mqtt_disable' addon option; skipping."
exit 0
fi
if [ ! -f "$CONFIG_LOCATION" ]; then
bashio::log.warning "Skipping MQTT auto-configuration: $CONFIG_LOCATION not found"
exit 0
fi
MQTT_HOST="$(bashio::services 'mqtt' 'host')"
MQTT_PORT="$(bashio::services 'mqtt' 'port')"
MQTT_USER="$(bashio::services 'mqtt' 'username')"
MQTT_PASS="$(bashio::services 'mqtt' 'password')"
MQTT_BROKER="tcp://${MQTT_HOST}:${MQTT_PORT}"
if ! bashio::config.true 'mqtt_auto_config'; then
bashio::log.green "---"
bashio::log.yellow "Home Assistant MQTT addon detected. Set 'mqtt_auto_config: true' in the addon options to wire it into BirdNET-Go automatically. Connection details:"
bashio::log.blue "MQTT user : ${MQTT_USER}"
bashio::log.blue "MQTT password: ${MQTT_PASS}"
bashio::log.blue "MQTT broker : ${MQTT_BROKER}"
bashio::log.green "---"
exit 0
fi
if [ ! -f "$CONFIG_LOCATION" ]; then
bashio::log.warning "Skipping MQTT auto-configuration: $CONFIG_LOCATION not found"
exit 0
fi
bashio::log.green "---"
bashio::log.blue "Home Assistant MQTT addon detected; auto-configuring BirdNET-Go"
bashio::log.blue "mqtt_auto_config enabled; writing Home Assistant MQTT credentials into BirdNET-Go config"
bashio::log.blue "Broker: ${MQTT_BROKER}"
bashio::log.blue "User: ${MQTT_USER}"
bashio::log.blue "(Set 'mqtt_disable: true' in addon options to opt out)"
bashio::log.green "---"
# $broker / $user / $pass / "birdnet" are jq/yq variables and literals,