From 80646bbf5130f23406c6fdbf5bfa85d973e3aa14 Mon Sep 17 00:00:00 2001 From: Linus Dietz <45101649+Dielee@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:47:42 +0100 Subject: [PATCH] Fix unknown state for icon update --- src/CHANGELOG.md | 7 +++++++ src/config.yaml | 2 +- src/const.py | 2 +- src/mqtt.py | 21 ++++++++++++--------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 015df5e..d50a783 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -1,3 +1,10 @@ +## v1.8.20 +### 🐛 Bug Fixes: + +- Fix Addon crash if icon state is `UNKOWN` +- Add `UNSPECIFIED` state for windows + + ## v1.8.19 ### 🐛 Bug Fixes: diff --git a/src/config.yaml b/src/config.yaml index a97d29f..36dfb8c 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,6 @@ name: "Volvo2Mqtt" description: "Volvo AAOS MQTT bridge" -version: "1.8.19" +version: "1.8.20" slug: "volvo2mqtt" init: false url: "https://github.com/Dielee/volvo2mqtt" diff --git a/src/const.py b/src/const.py index 3db9956..40e2915 100644 --- a/src/const.py +++ b/src/const.py @@ -1,6 +1,6 @@ from config import settings -VERSION = "v1.8.19" +VERSION = "v1.8.20" OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles" diff --git a/src/mqtt.py b/src/mqtt.py index 5a213d3..4075e44 100644 --- a/src/mqtt.py +++ b/src/mqtt.py @@ -269,16 +269,19 @@ def update_car_data(force_update=False, overwrite={}): def update_ha_device(entity, vin, state): icon_config = icon_states.get(entity["id"]) - if icon_config and state: - logging.debug("Entity " + entity["id"] + " state " + str(state)) - if isinstance(state, float): - icon = util.get_icon_between(icon_config, state) - elif state.replace(".", "").isnumeric(): - state = float(state) - icon = util.get_icon_between(icon_config, state) + try: + if icon_config and state: + logging.debug("Entity " + entity["id"] + " state " + str(state)) + if isinstance(state, float): + icon = util.get_icon_between(icon_config, state) + elif state.replace(".", "").isnumeric(): + state = float(state) + icon = util.get_icon_between(icon_config, state) + else: + icon = icon_config[state] else: - icon = icon_config[state] - else: + return None + except: return None logging.debug("Updating icon to " + icon + " for " + entity["id"])