Use try/except for numeric state conversion instead of str.isnumeric()
This commit is contained in:
parent
3e9d362805
commit
82acfd3718
@ -62,9 +62,10 @@ class Entities(nagiosplugin.Resource):
|
|||||||
uom = None
|
uom = None
|
||||||
else:
|
else:
|
||||||
if self.numeric:
|
if self.numeric:
|
||||||
value = (
|
try:
|
||||||
float(state["state"]) if state["state"].isnumeric() else -1
|
value = float(state["state"])
|
||||||
)
|
except ValueError:
|
||||||
|
value = -1
|
||||||
else:
|
else:
|
||||||
value = state["state"]
|
value = state["state"]
|
||||||
uom = state["attributes"].get("unit_of_measurement")
|
uom = state["attributes"].get("unit_of_measurement")
|
||||||
|
Loading…
Reference in New Issue
Block a user