From 3f3636877381963f6035120921cc375c78739575 Mon Sep 17 00:00:00 2001 From: linus Date: Wed, 25 Sep 2024 07:39:23 +0200 Subject: [PATCH] Optimize vcc api key check --- src/CHANGELOG.md | 6 ++++++ src/config.yaml | 2 +- src/const.py | 2 +- src/volvo.py | 12 ++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 5bd4a3e..894a69f 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -1,5 +1,11 @@ +## v1.10.1 +### 🚀 Features: + +- Optimize logging for vcc-api-key check #238 + ## v1.10.0 ### 🚀 Features: + - Remove unused multiplier options ### 🐛 Bug Fixes: diff --git a/src/config.yaml b/src/config.yaml index 8ea49ed..182752c 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,6 @@ name: "Volvo2Mqtt" description: "Volvo AAOS MQTT bridge" -version: "1.10.0" +version: "1.10.1" slug: "volvo2mqtt" init: false url: "https://github.com/Dielee/volvo2mqtt" diff --git a/src/const.py b/src/const.py index b73449c..49eb69f 100644 --- a/src/const.py +++ b/src/const.py @@ -1,6 +1,6 @@ from config import settings -VERSION = "v1.10.0" +VERSION = "v1.10.1" 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/volvo.py b/src/volvo.py index aaa562c..c7fd548 100644 --- a/src/volvo.py +++ b/src/volvo.py @@ -311,9 +311,17 @@ def check_vcc_api_key(test_key, extended_until=None): logging.warning("VCCAPIKEY " + test_key + " is extended and will be reusable at: " + format_datetime(extended_until, format="medium", locale=settings["babelLocale"])) else: - logging.warning("VCCAPIKEY " + test_key + " isn't working! " + data["error"]["message"]) + if "error" in data: + logging.warning("VCCAPIKEY " + test_key + " isn't working! " + data["error"]["message"]) + else: + logging.warning("VCCAPIKEY " + test_key + " isn't working! Statuscode " + str(response.status_code) + + " Message: " + response.text) else: - logging.warning("VCCAPIKEY " + test_key + " isn't working! " + data["error"]["message"]) + if "error" in data: + logging.warning("VCCAPIKEY " + test_key + " isn't working! " + data["error"]["message"]) + else: + logging.warning("VCCAPIKEY " + test_key + " isn't working! Statuscode " + str(response.status_code) + + " Message: " + response.text) return True, extended_until