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