From 0931c367c79c1ff6640ebba3bfb67605075552b6 Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Sun, 29 Jan 2023 20:07:01 -0700 Subject: [PATCH] proper data types Signed-off-by: Travis Glenn Hansen --- CHANGELOG.md | 6 ++++++ custom_components/pfsense/sensor.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4c6480..67274a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.5.13 + +Released 2023-01-29 + +- ensure proper data type + # v0.5.12 Released 2023-01-29 diff --git a/custom_components/pfsense/sensor.py b/custom_components/pfsense/sensor.py index 9d5bffa..533a492 100644 --- a/custom_components/pfsense/sensor.py +++ b/custom_components/pfsense/sensor.py @@ -613,7 +613,12 @@ def native_value(self): value = gateway[property] # cleanse "ms", etc from values if property in ["stddev", "delay", "loss"]: - value = re.sub("[^0-9\.]*", "", value) + if isinstance(value, str): + value = re.sub("[^0-9\.]*", "", value) + value = float(value) + + if isinstance(value, str) and len(value) < 1: + return STATE_UNKNOWN return value except KeyError: