birdnet-go: guard SQLite revert to only run when HA MariaDB host matches

When mariadb_auto_config is disabled, only revert output.mysql.enabled to
false (and re-enable SQLite) if config.yaml's output.mysql.host matches the
HA MariaDB service host. This prevents clobbering a manually-configured
MySQL block pointing at a different server on every addon restart.
This commit is contained in:
Claude
2026-06-23 08:55:32 +00:00
parent 6d3b19dbac
commit 97c165b59a
2 changed files with 11 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
## nightly-20260615-2 (2026-06-23)
- MariaDB auto-config: create the `birdnet` database on first start if it does not exist (birdnet-go connects to a pre-existing schema and does not create it, causing "database doesn't exist" errors)
- MariaDB auto-config: disabling `mariadb_auto_config` now writes `output.mysql.enabled = false` and `output.sqlite.enabled = true` back to config.yaml, so turning the option off fully reverts to SQLite
- MariaDB auto-config: disabling `mariadb_auto_config` now reverts to SQLite only when `output.mysql.host` in config.yaml matches the HA MariaDB host (avoids clobbering manually-configured MySQL pointing at a different server)
- Added `mariadb-client` to the addon packages so the `mysql` CLI used for database creation is available inside the container
- MQTT auto-config now also enables BirdNET-Go's native Home Assistant MQTT auto-discovery: detection sensors appear in Home Assistant automatically with no manual YAML (existing UI/config.yaml edits are preserved)

View File

@@ -41,13 +41,18 @@ if ! bashio::config.true 'mariadb_auto_config'; then
bashio::log.blue "Port : ${MYSQL_PORT}"
bashio::log.green "---"
if [ -f "$CONFIG_LOCATION" ]; then
# Revert any previously written mysql block so the app uses SQLite.
# Only revert if config.yaml points at the HA MariaDB host we would have
# written — a mysql block pointing at a different host was set manually.
# shellcheck disable=SC2016
CURRENT_MYSQL_HOST="$(yq -r '.output.mysql.host // empty' "$CONFIG_LOCATION" 2>/dev/null || true)"
if yq -e '.output.mysql.enabled == true' "$CONFIG_LOCATION" >/dev/null 2>&1 \
&& [ "${CURRENT_MYSQL_HOST}" = "${MYSQL_HOST}" ]; then
yq -i -y \
'.output.mysql.enabled = false
| .output.sqlite.enabled = true' \
"$CONFIG_LOCATION"
fi
fi
exit 0
fi