From f650ea924727c1a0543cbb6661cc67abe318b447 Mon Sep 17 00:00:00 2001 From: Linus Dietz <45101649+Dielee@users.noreply.github.com> Date: Wed, 29 May 2024 20:08:19 +0200 Subject: [PATCH] Fix retained otp messages bug --- src/CHANGELOG.md | 5 +++++ src/config.yaml | 2 +- src/const.py | 2 +- src/mqtt.py | 9 ++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 866bbf3..7c3c14b 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -1,3 +1,8 @@ +## v1.9.3 +### 🐛 Bug Fixes: + +- Ignore retained OTP messages #193 + ## v1.9.2 ### 🐛 Bug Fixes: diff --git a/src/config.yaml b/src/config.yaml index a9281a0..ec06154 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,6 @@ name: "Volvo2Mqtt" description: "Volvo AAOS MQTT bridge" -version: "1.9.2" +version: "1.9.3" slug: "volvo2mqtt" init: false url: "https://github.com/Dielee/volvo2mqtt" diff --git a/src/const.py b/src/const.py index 5f944f4..37e8a89 100644 --- a/src/const.py +++ b/src/const.py @@ -1,6 +1,6 @@ from config import settings -VERSION = "v1.9.2" +VERSION = "v1.9.3" OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2" diff --git a/src/mqtt.py b/src/mqtt.py index 0ee1699..6cec313 100644 --- a/src/mqtt.py +++ b/src/mqtt.py @@ -131,9 +131,12 @@ def on_disconnect(client, userdata, rc): def on_message(client, userdata, msg): payload = msg.payload.decode("UTF-8") if msg.topic == otp_mqtt_topic: - global otp_code - otp_code = payload - set_otp_state() + if msg.retain == 0: + global otp_code + otp_code = payload + set_otp_state() + else: + logging.warning("Found retained OTP, this can't work! Pleas clean retained messages!") return None else: try: