From e0a4ca3598ce251f788e5ca21da1a9bb393c40b0 Mon Sep 17 00:00:00 2001 From: Ernst Klamer Date: Tue, 27 Feb 2024 10:32:18 +0100 Subject: [PATCH] error handling --- custom_components/ble_monitor/ble_parser/oras.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom_components/ble_monitor/ble_parser/oras.py b/custom_components/ble_monitor/ble_parser/oras.py index fb2272e0..441a94d5 100644 --- a/custom_components/ble_monitor/ble_parser/oras.py +++ b/custom_components/ble_monitor/ble_parser/oras.py @@ -38,7 +38,17 @@ def parse_oras(self, data: bytes, mac: str): except ValueError: return None - sensor_data = int(data[8:11].decode("ASCII")) + try: + sensor_data = int(data[8:11].decode("ASCII")) + except ValueError: + error_code = data[8:11].decode("ASCII") + _LOGGER.error( + "Garnet SeeLevel II 709-BTP3 is reporting error %s for sensor %s", + error_code, + sensor_type + ) + return None + if sensor_id == 13: sensor_data /= 10