Compare commits

..
5 Commits
Author SHA1 Message Date
jarvis bf6568d945 fix: full patch - reconnect_delay, keepalive, clean_session, QoS1
Patches for paho-mqtt rc=7 at startup (MQTT_ERR_CONN_LOST):

1. reconnect_delay_set(1, 30) - auto-reconnect with backoff
2. keepalive=120 - prevents timeout during long OTP startup
3. subscribe(otp_topic) in on_connect - no race condition
4. time.sleep(0.05) - prevents TCP socket buffer overflow
5. clean_session=False - queued messages survive reconnect
6. qos=1 for discovery configs - PUBACK confirms delivery
2026-06-24 17:05:49 +02:00
linus f8b6f9cf53 Move to base python 2026-05-15 09:30:54 +02:00
linus 7c32ca59be Add build.yaml for homeassistant version > 2026.04.X 2026-05-15 09:29:01 +02:00
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
5 changed files with 33 additions and 7 deletions
+12
View File
@@ -1,3 +1,15 @@
## v1.13.5
### 🐛 Bug Fixes:
- Add build.yaml for homeassistant version > 2026.04.X
## 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:
+6
View File
@@ -0,0 +1,6 @@
build_from:
amd64: ghcr.io/home-assistant/base-python:latest
aarch64: ghcr.io/home-assistant/base-python:latest
armv7: ghcr.io/home-assistant/base-python:latest
armhf: ghcr.io/home-assistant/base-python:latest
i386: ghcr.io/home-assistant/base-python:latest
+1 -1
View File
@@ -1,6 +1,6 @@
name: "Volvo2Mqtt"
description: "Volvo AAOS MQTT bridge"
version: "1.13.3"
version: "1.13.5"
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.5"
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
+13 -5
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, clean_session=False)
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")
@@ -36,6 +40,7 @@ def connect():
client.on_message = safe_on_message
client.on_disconnect = on_disconnect
client.on_connect = on_connect
client.reconnect_delay_set(min_delay=1, max_delay=30)
client.will_set(availability_topic, "offline", 0, False)
if settings["mqtt"]["username"] and settings["mqtt"]["password"]:
@@ -46,10 +51,9 @@ def connect():
if isinstance(conf_port, int):
if conf_port > 0:
port = settings["mqtt"]["port"]
client.connect(settings["mqtt"]["broker"], port)
client.connect(settings["mqtt"]["broker"], port, 120)
client.loop_start()
client.subscribe("volvoAAOS2mqtt/otp_code")
global mqtt_client
mqtt_client = client
@@ -141,6 +145,7 @@ def on_connect(client, userdata, flags, rc):
logging.info("MQTT connected")
send_heartbeat()
mqtt_client.subscribe("volvoAAOS2mqtt/otp_code")
if len(subscribed_topics) > 0:
for topic in subscribed_topics:
mqtt_client.subscribe(topic)
@@ -435,6 +440,7 @@ def update_ha_device(entity, vin, state):
mqtt_client.publish(
f"homeassistant/{entity['domain']}/volvoAAOS2mqtt/{vin}_{entity['id']}/config",
json.dumps(config),
qos=1,
retain=True
)
@@ -485,8 +491,10 @@ def create_ha_devices():
mqtt_client.publish(
f"homeassistant/{entity['domain']}/volvoAAOS2mqtt/{vin}_{entity['id']}/config",
json.dumps(config),
qos=1,
retain=True
)
time.sleep(0.05)
time.sleep(2)
send_heartbeat()