Besseres Fehlerverhalten bei fehlendem Scaler

This commit is contained in:
Andreas Thienemann 2022-02-27 05:43:33 +01:00
parent 4fcf826e03
commit ce17b68bfb

View File

@ -84,12 +84,16 @@ class TasmotaSMLParser:
f"{round(msg.value * pow(10, msg.scaler), precision)}{unit} ({name})"
)
except TypeError:
if msg.unit in UNITS and msg.name in OBIS_NAMES:
try:
human_readable = f"{msg.value}{unit} ({name})"
elif msg.unit in UNITS and msg.name not in OBIS_NAMES:
except:
try:
human_readable = f"{msg.value}{unit}"
else:
except:
try:
human_readable = f"{msg.value}"
except:
human_readable = ""
data = {
"obis": msg.obis,