fix(media_player): the adb_command participant registry key is computed once at registration and stored on the entity — add/remove always match (F4)
This commit is contained in:
1 parent
c44c2c2170
commit
b37a14b920
5 files changed
+147
-60
No files matched your search
@@ -1039,60 +1039,3 @@ def _adb_command_service_maybe_remove(hass) -> None:
|
||||
DOMAIN, SERVICE_ADB_COMMAND
|
||||
):
|
||||
hass.services.async_remove(DOMAIN, SERVICE_ADB_COMMAND)
|
||||
|
||||
|
||||
# ── P4-2b: diagnostics ──
|
||||
|
||||
_REDACT_KEY_MARKERS = ("pairing", "pin", "secret", "password", "token", "key_material")
|
||||
_REDACTED = "**REDACTED**"
|
||||
|
||||
|
||||
def _redact(obj):
|
||||
"""Redact sensitive keys from a JSON-ish diagnostics payload."""
|
||||
if isinstance(obj, dict):
|
||||
return {
|
||||
key: (
|
||||
_REDACTED
|
||||
if any(m in str(key).lower() for m in _REDACT_KEY_MARKERS)
|
||||
else _redact(value)
|
||||
)
|
||||
for key, value in obj.items()
|
||||
}
|
||||
if isinstance(obj, list):
|
||||
return [_redact(item) for item in obj]
|
||||
return obj
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(hass, entry):
|
||||
"""Entry diagnostics (P4-2b): redacted config + store + transport health.
|
||||
|
||||
HA resolves diagnostics from a ``diagnostics`` module; the function is
|
||||
import-ready there — kept in this module until a pure-diagnostics file
|
||||
is added (Phase 4 trim).
|
||||
"""
|
||||
import dataclasses
|
||||
|
||||
manager = getattr(entry, "runtime_data", None)
|
||||
payload: dict = {
|
||||
"entry": {
|
||||
"data": dict(getattr(entry, "data", {}) or {}),
|
||||
"options": dict(getattr(entry, "options", {}) or {}),
|
||||
},
|
||||
"store": {},
|
||||
"transport": {},
|
||||
}
|
||||
if manager is not None:
|
||||
snapshot = getattr(manager.store, "_values", {})
|
||||
for name, (stamp, value) in snapshot.items():
|
||||
if dataclasses.is_dataclass(value) and not isinstance(value, type):
|
||||
value = dataclasses.asdict(value)
|
||||
payload["store"][name] = {"age": round(time.monotonic() - stamp, 3), "value": value}
|
||||
payload["transport"] = {
|
||||
"adb": {"connected": manager.connected, "awake": manager.awake},
|
||||
"protocol": {
|
||||
"active": manager.protocol_active,
|
||||
"available": manager.is_available,
|
||||
"is_on": manager.is_on,
|
||||
},
|
||||
}
|
||||
return _redact(payload)
|
||||
Reference in new issue
Block a user