From 41168fbb4d5a461ab8d04cafa908b26b0278e91c Mon Sep 17 00:00:00 2001 From: Stefan Allius <122395479+s-allius@users.noreply.github.com> Date: Sat, 31 May 2025 23:30:16 +0200 Subject: [PATCH] S allius/issue438 (#442) * Update change log (#436) * S allius/issue427 (#434) * mock the aiomqtt library and increse coverage * test inv response for a mb scan request * improve test coverage * S allius/issue427 (#435) * mock the aiomqtt library and increse coverage * test inv response for a mb scan request * improve test coverage * improve test case * version 0.14.0 * handle missing MQTT addon - we have to check if the supervisor API and a MQTT broker add-on is installed. If not we assume the user has an external MQTT broker * handle missing MQTT addon * run also on releases/* branch * avoid printing of the MQTT config inkl. password * revise the log outputs * update version 0.14.1 * new version 0.14.1 --- .github/workflows/python-app.yml | 4 ++-- CHANGELOG.md | 6 +++++- app/.version | 2 +- ha_addons/ha_addon/rootfs/run.sh | 31 +++++++++++++++++++++---------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index ae65cd7..c67a313 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -5,7 +5,7 @@ name: Python application on: push: - branches: [ "main", "dev-*", "*/issue*" ] + branches: [ "main", "dev-*", "*/issue*", "releases/*" ] paths-ignore: - '**.md' # Do no build on *.md changes - '**.yml' # Do no build on *.yml changes @@ -18,7 +18,7 @@ on: - '**.dockerfile' # Do no build on *.dockerfile changes - '**.sh' # Do no build on *.sh changes pull_request: - branches: [ "main", "dev-*" ] + branches: [ "main", "dev-*", "releases/*" ] permissions: contents: read diff --git a/CHANGELOG.md b/CHANGELOG.md index 88457d1..87342ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [unreleased] +## [0.14.1] - 2025-05-31 + +- handle missing MQTT addon [#438](https://github.com/s-allius/tsun-gen3-proxy/issues/438) + +## [0.14.0] - 2025-05-29 ## [0.14.0] - 2025-05-29 diff --git a/app/.version b/app/.version index 0548fb4..c39e9c5 100644 --- a/app/.version +++ b/app/.version @@ -1 +1 @@ -0.14.0 \ No newline at end of file +0.14.1 \ No newline at end of file diff --git a/ha_addons/ha_addon/rootfs/run.sh b/ha_addons/ha_addon/rootfs/run.sh index 6c231e4..c2dc223 100755 --- a/ha_addons/ha_addon/rootfs/run.sh +++ b/ha_addons/ha_addon/rootfs/run.sh @@ -1,18 +1,28 @@ #!/usr/bin/with-contenv bashio -echo "Add-on environment started" - -echo "check for Home Assistant MQTT" -MQTT_HOST=$(bashio::services mqtt "host") -MQTT_PORT=$(bashio::services mqtt "port") -MQTT_USER=$(bashio::services mqtt "username") -MQTT_PASSWORD=$(bashio::services mqtt "password") +bashio::log.blue "-----------------------------------------------------------" +bashio::log.blue "run.sh: info: setup Add-on environment" +bashio::cache.flush_all +MQTT_HOST="" +if bashio::supervisor.ping; then + bashio::log "run.sh: info: check for Home Assistant MQTT service" + if bashio::services.available mqtt; then + MQTT_HOST=$(bashio::services mqtt "host") + MQTT_PORT=$(bashio::services mqtt "port") + MQTT_USER=$(bashio::services mqtt "username") + MQTT_PASSWORD=$(bashio::services mqtt "password") + else + bashio::log.yellow "run.sh: info: Home Assistant MQTT service not available!" + fi +else + bashio::log.red "run.sh: error: Home Assistant Supervisor API not available!" +fi # if a MQTT was/not found, drop a note if [ -z "$MQTT_HOST" ]; then - echo "MQTT not found" + bashio::log.yellow "run.sh: info: MQTT config not found" else - echo "MQTT found" + bashio::log.green "run.sh: info: MQTT config found" export MQTT_HOST export MQTT_PORT export MQTT_USER @@ -29,5 +39,6 @@ cd /home/proxy || exit export VERSION=$(cat /proxy-version.txt) -echo "Start Proxyserver..." +bashio::log.blue "run.sh: info: Start Proxyserver..." +bashio::log.blue "-----------------------------------------------------------" python3 server.py --rel_urls --json_config=/data/options.json --log_path=/homeassistant/tsun-proxy/logs/ --config_path=/homeassistant/tsun-proxy/ --log_backups=2