From ce856d91c45676e713285a0f8d477aa10e645eae Mon Sep 17 00:00:00 2001 From: Linus Dietz <45101649+Dielee@users.noreply.github.com> Date: Tue, 23 Jan 2024 08:42:37 +0100 Subject: [PATCH] Fix #165 --- src/mqtt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mqtt.py b/src/mqtt.py index 9d7331f..f79a55f 100644 --- a/src/mqtt.py +++ b/src/mqtt.py @@ -265,7 +265,11 @@ def update_car_data(force_update=False, overwrite={}): f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/attributes", json.dumps(state) ) - state = sum(value == "FAILURE" for value in state.values()) + if state: + state = sum(value == "FAILURE" for value in state.values()) + else: + state = 0 + topic = f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/state" else: topic = f"homeassistant/{entity['domain']}/{vin}_{entity['id']}/state"