Use try/except for numeric state conversion instead of str.isnumeric()

This commit is contained in:
Adam Goldsmith 2023-01-03 12:16:15 -05:00
parent 3e9d362805
commit 82acfd3718

View File

@ -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")