From 38a0d206c3ba0075d671349d06379bfa0c55b171 Mon Sep 17 00:00:00 2001 From: Marco Rossi Date: Mon, 14 Oct 2024 20:51:55 +0200 Subject: [PATCH] Fix handle ConnectionError and ValueError differently Close #6 --- custom_components/dashboard_delbrueck/sensor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/dashboard_delbrueck/sensor.py b/custom_components/dashboard_delbrueck/sensor.py index ee70933..2bfc882 100644 --- a/custom_components/dashboard_delbrueck/sensor.py +++ b/custom_components/dashboard_delbrueck/sensor.py @@ -73,7 +73,9 @@ def update(self): else: self._attr_native_value = data["value"] self._attr_native_unit_of_measurement = UNIT_CONVERTER[data["unit"]] - except (ValueError, ConnectionError): + except ConnectionError: + self._attr_native_value = None + except ValueError: self._attr_native_value = None if "unit" in data and data["unit"] in UNIT_CONVERTER: self._attr_native_unit_of_measurement = UNIT_CONVERTER[data["unit"]]