Compare commits

...
2 Commits
Author SHA1 Message Date
linus 67948b0900 Bump version 2026-05-15 09:10:56 +02:00
48663d2e0d Fix AttributeError for paho-mqtt < 2.0 compatibility (#321)
When paho-mqtt < 2.0 is installed (e.g. in cached Docker layers),
mqtt.CallbackAPIVersion does not exist, causing an immediate crash on
startup with:

  AttributeError: module 'paho.mqtt.client' has no attribute 'CallbackAPIVersion'

Add try/except fallback so the addon works with both paho-mqtt 1.x and
2.x, eliminating the crash and allowing the addon to start correctly.

Co-authored-by: Barry Jarman <bazza@Barrys-Mac-mini.local>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-15 09:09:26 +02:00
4 changed files with 15 additions and 5 deletions
+6
View File
@@ -1,3 +1,9 @@
## v1.13.4
### 🐛 Bug Fixes:
- Fix `AttributeError: module 'paho.mqtt.client' has no attribute 'CallbackAPIVersion'` when paho-mqtt < 2.0 is installed
## v1.13.3
### 🐛 Bug Fixes:
+1 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.13.3"
version: "1.13.4"
slug: "volvo2mqtt"
init: false
url: "https://github.com/Dielee/volvo2mqtt"
+1 -1
View File
@@ -1,6 +1,6 @@
from config import settings
VERSION = "v1.13.3"
VERSION = "v1.13.4"
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
+7 -3
View File
@@ -25,9 +25,13 @@ active_schedules = {}
otp_code = None
def connect():
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, "volvoAAOS2mqtt") \
if os.environ.get("IS_HA_ADDON") \
else mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, "volvoAAOS2mqtt_" + settings.volvoData["username"].replace("+", ""))
client_id = "volvoAAOS2mqtt" if os.environ.get("IS_HA_ADDON") \
else "volvoAAOS2mqtt_" + settings.volvoData["username"].replace("+", "")
try:
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, client_id)
except AttributeError:
# paho-mqtt < 2.0 does not have CallbackAPIVersion
client = mqtt.Client(client_id)
if "logging" in settings["mqtt"] and settings["mqtt"]["logging"]:
mqtt_logger = logging.getLogger("mqtt")