We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f30325a commit c5d8262Copy full SHA for c5d8262
plugwise/util.py
@@ -193,9 +193,13 @@ def escape_illegal_xml_characters(xmldata: str) -> str:
193
return re.sub(r"&([^a-zA-Z#])", r"&\1", xmldata)
194
195
196
-def format_measure(measure: str, unit: str) -> float | int:
+def format_measure(measure: str, unit: str) -> float | int | str:
197
"""Format measure to correct type."""
198
- float_measure = float(measure)
+ try:
199
+ float_measure = float(measure)
200
+ except ValueError as exc:
201
+ return measure # return string
202
+
203
if unit == PERCENTAGE and 0 < float_measure <= 1:
204
return int(float_measure * 100)
205
0 commit comments