From bd1f93ef0f62076acf1745483de2489ee856445d Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Sun, 29 Jan 2023 21:14:52 -0700 Subject: [PATCH] unavailable logic Signed-off-by: Travis Glenn Hansen --- CHANGELOG.md | 6 ++++++ custom_components/pfsense/sensor.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af6a27..b225cb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.5.15 + +Released 2023-01-29 + +- better unavailable logic + # v0.5.14 Released 2023-01-29 diff --git a/custom_components/pfsense/sensor.py b/custom_components/pfsense/sensor.py index 2ddbcc2..8f6da99 100644 --- a/custom_components/pfsense/sensor.py +++ b/custom_components/pfsense/sensor.py @@ -580,6 +580,13 @@ def available(self) -> bool: if gateway is None or property not in gateway.keys(): return False + if property in ["stddev", "delay", "loss"]: + value = gateway[property] + if isinstance(value, str): + value = re.sub("[^0-9\.]*", "", value) + if len(value) < 1: + return False + return super().available @property