diff --git a/check_home_assistant_state.py b/check_home_assistant_state.py index 4624d24..544ec78 100755 --- a/check_home_assistant_state.py +++ b/check_home_assistant_state.py @@ -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")