Filter out Unraid infrastructure entities from HA smart-home view

Exclude Docker container power switches, system service switches,
VM switches, and hardware monitoring sensors (disk/CPU/GPU temps)
from the dashboard. Only show actual smart-home entities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sam 2026-03-02 19:36:37 +01:00
parent f5b7c53f18
commit 3235e6293a

View file

@ -112,6 +112,38 @@ _SENSOR_CLASSES = {"temperature", "humidity"}
# Binary sensor device_classes we display
_BINARY_SENSOR_CLASSES = {"door", "window", "motion", "occupancy"}
# ---------------------------------------------------------------------------
# Filters — exclude Unraid infrastructure entities from the smart-home view.
# Unraid integration exposes Docker containers, system services, VMs,
# disk temps, CPU/GPU temps etc. as HA entities. They clutter the dashboard.
# ---------------------------------------------------------------------------
# Switches whose friendly_name starts with these are hidden
_SWITCH_EXCLUDE_PREFIXES = (
"Daddelolymp Docker:",
"Daddelolymp Service:",
"Daddelolymp VM:",
"Daddelolymp Array:",
"Moneyboy Docker:",
"Moneyboy Service:",
"Moneyboy VM:",
"Moneyboy Array:",
)
# Also exclude exact switch names that are server-level, not smart-home
_SWITCH_EXCLUDE_EXACT = {
"Daddelolymp",
"Moneyboy",
}
# Sensor friendly_names containing these substrings are hardware, not room sensors
_SENSOR_EXCLUDE_SUBSTRINGS = (
"System: CPU",
"System: Motherboard",
"Disk:",
"GPU:",
)
# ---------------------------------------------------------------------------
# Fetch all entity states
@ -178,10 +210,17 @@ async def fetch_ha_data(url: str, token: str) -> Dict[str, Any]:
if state in ("unavailable", "unknown"):
continue
friendly = _friendly_name(entity)
if domain == "light":
lights.append(_parse_light(entity))
elif domain == "switch":
# Skip Unraid infrastructure switches
if friendly in _SWITCH_EXCLUDE_EXACT:
continue
if any(friendly.startswith(p) for p in _SWITCH_EXCLUDE_PREFIXES):
continue
switches.append(_parse_switch(entity))
elif domain == "cover":
@ -190,6 +229,9 @@ async def fetch_ha_data(url: str, token: str) -> Dict[str, Any]:
elif domain == "sensor":
device_class = attrs.get("device_class", "")
if device_class in _SENSOR_CLASSES:
# Skip hardware monitoring sensors (disk/CPU/GPU temps)
if any(sub in friendly for sub in _SENSOR_EXCLUDE_SUBSTRINGS):
continue
sensors.append(_parse_sensor(entity))
elif domain == "binary_sensor":