Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Support more event type on/off + ignore brightness #14

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom_components/datadog_agentless/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading