History stats sensor prioritized
This commit is contained in:
parent
23af597701
commit
844e15a797
1 changed files with 28 additions and 0 deletions
|
|
@ -125,6 +125,17 @@ IMPORTANT_ENTITY_KEYWORDS = {
|
|||
"smb_": 60,
|
||||
}
|
||||
|
||||
HISTORY_STATS_MARKERS = {
|
||||
"_daily",
|
||||
"_weekly",
|
||||
"_monthly",
|
||||
"_last7days",
|
||||
"_last_7_days",
|
||||
"_work_hours",
|
||||
"_flex_hours",
|
||||
"_count_sql",
|
||||
}
|
||||
|
||||
|
||||
class ConfigError(RuntimeError):
|
||||
pass
|
||||
|
|
@ -480,6 +491,18 @@ def display_time(value: str | None) -> str:
|
|||
return value
|
||||
|
||||
|
||||
def looks_like_history_stats_sensor(entity_id: str, attrs: dict[str, Any] | None = None) -> bool:
|
||||
attrs = attrs or {}
|
||||
if not entity_id.startswith("sensor."):
|
||||
return False
|
||||
text = f"{entity_id} {attrs.get('friendly_name', '')}".lower()
|
||||
if any(marker in text for marker in HISTORY_STATS_MARKERS):
|
||||
return True
|
||||
if any(marker in text for marker in {"work hours", "flex hours"}):
|
||||
return True
|
||||
return attrs.get("device_class") == "duration" and any(marker in text for marker in {"hours today", "hours this week"})
|
||||
|
||||
|
||||
def entity_importance(entity_id: str, attrs: dict[str, Any] | None = None) -> int:
|
||||
attrs = attrs or {}
|
||||
domain = entity_id.split(".", 1)[0]
|
||||
|
|
@ -505,6 +528,11 @@ def entity_importance(entity_id: str, attrs: dict[str, Any] | None = None) -> in
|
|||
if keyword in text:
|
||||
score += points
|
||||
|
||||
# History Stats sensors summarize behavior over a day/week/month; keep them
|
||||
# above lower-value chatter when snapshots are capped.
|
||||
if looks_like_history_stats_sensor(entity_id, attrs):
|
||||
score += 220
|
||||
|
||||
# Sønderborg/Denmark home is the primary residence and absolute priority.
|
||||
# Samobor/Croatia entities use the smb_ prefix and are still included, but
|
||||
# they should lose ties when the LLM input has to be size-limited.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue