From b6e9012f393dd9a6d6a3a89d59eac4c6cabef3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Seux?= Date: Sun, 22 Sep 2024 20:00:56 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20more=20event=20type=20on/?= =?UTF-8?q?off=20+=20ignore=20brightness?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/datadog_agentless/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/datadog_agentless/__init__.py b/custom_components/datadog_agentless/__init__.py index 7a3b24e..92bfc43 100644 --- a/custom_components/datadog_agentless/__init__.py +++ b/custom_components/datadog_agentless/__init__.py @@ -196,7 +196,7 @@ def _extract_state(new_state: State, entity_id: str, value: Any, main_state: boo if isinstance(value, datetime.datetime): return value.timestamp() # let's ignore "known" string values - if str(value).lower() in ["unavailable", "unknown", "info", "warn", "debug", "error", "false", "none", "on/off", "off/on", "restore", "up", "down", "stop", "opening", "", "scene_mode", "sunny", "near", "far", "cloud", "partlycloudy"]: + if str(value).lower() in ["unavailable", "unknown", "info", "warn", "debug", "error", "false", "none", "on/off", "off/on", "restore", "up", "down", "stop", "opening", "", "scene_mode", "sunny", "near", "far", "cloud", "partlycloudy", "brightness"]: return None # we can treat timestamps @@ -219,9 +219,9 @@ def _extract_state(new_state: State, entity_id: str, value: Any, main_state: boo _LOGGER.warn(f"Unable to parse {value} as a timestamp, even if it looks like one") # some values can reasonnably be converted to numeric value - if value.lower() in ["unprotected", "dead", "disabled", "inactive", "unlock"]: + if value.lower() in ["unprotected", "dead", "disabled", "inactive", "unlock", "off"]: return 0 - if value.lower() in ["alive", "ready", "enabled", "pending", "lock"]: + if value.lower() in ["alive", "ready", "enabled", "pending", "lock", "on"]: return 1 # looks like a ssid