mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Minor changes on AndroidTV diagnostics (#69197)
This commit is contained in:
parent
4b5033d08f
commit
add01d434e
@ -5,7 +5,7 @@ from typing import Any
|
|||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import REDACTED, async_redact_data
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_CONNECTIONS, ATTR_IDENTIFIERS, CONF_UNIQUE_ID
|
from homeassistant.const import ATTR_CONNECTIONS, ATTR_IDENTIFIERS, CONF_UNIQUE_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -14,7 +14,8 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
|||||||
from .const import ANDROID_DEV, DOMAIN, PROP_ETHMAC, PROP_SERIALNO, PROP_WIFIMAC
|
from .const import ANDROID_DEV, DOMAIN, PROP_ETHMAC, PROP_SERIALNO, PROP_WIFIMAC
|
||||||
|
|
||||||
TO_REDACT = {CONF_UNIQUE_ID} # UniqueID contain MAC Address
|
TO_REDACT = {CONF_UNIQUE_ID} # UniqueID contain MAC Address
|
||||||
TO_REDACT_DEV = {PROP_ETHMAC, PROP_SERIALNO, PROP_WIFIMAC}
|
TO_REDACT_DEV = {ATTR_CONNECTIONS, ATTR_IDENTIFIERS}
|
||||||
|
TO_REDACT_DEV_PROP = {PROP_ETHMAC, PROP_SERIALNO, PROP_WIFIMAC}
|
||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
@ -26,13 +27,10 @@ async def async_get_config_entry_diagnostics(
|
|||||||
|
|
||||||
# Get information from AndroidTV library
|
# Get information from AndroidTV library
|
||||||
aftv = hass_data[ANDROID_DEV]
|
aftv = hass_data[ANDROID_DEV]
|
||||||
data_dev = {"device_class": aftv.DEVICE_CLASS}
|
data["device_properties"] = {
|
||||||
for prop, value in aftv.device_properties.items():
|
**async_redact_data(aftv.device_properties, TO_REDACT_DEV_PROP),
|
||||||
if prop in TO_REDACT_DEV and value:
|
"device_class": aftv.DEVICE_CLASS,
|
||||||
data_dev[prop] = REDACTED
|
}
|
||||||
else:
|
|
||||||
data_dev[prop] = value
|
|
||||||
data["device_properties"] = data_dev
|
|
||||||
|
|
||||||
# Gather information how this AndroidTV device is represented in Home Assistant
|
# Gather information how this AndroidTV device is represented in Home Assistant
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
@ -44,12 +42,9 @@ async def async_get_config_entry_diagnostics(
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
data["device"] = {
|
data["device"] = {
|
||||||
**attr.asdict(hass_device),
|
**async_redact_data(attr.asdict(hass_device), TO_REDACT_DEV),
|
||||||
"entities": {},
|
"entities": {},
|
||||||
}
|
}
|
||||||
data["device"][ATTR_IDENTIFIERS] = REDACTED
|
|
||||||
if ATTR_CONNECTIONS in data["device"]:
|
|
||||||
data["device"][ATTR_CONNECTIONS] = REDACTED
|
|
||||||
|
|
||||||
hass_entities = er.async_entries_for_device(
|
hass_entities = er.async_entries_for_device(
|
||||||
entity_registry,
|
entity_registry,
|
||||||
@ -67,15 +62,14 @@ async def async_get_config_entry_diagnostics(
|
|||||||
# The context doesn't provide useful information in this case.
|
# The context doesn't provide useful information in this case.
|
||||||
state_dict.pop("context", None)
|
state_dict.pop("context", None)
|
||||||
|
|
||||||
entity_dict = async_redact_data(
|
data["device"]["entities"][entity_entry.entity_id] = {
|
||||||
{
|
**async_redact_data(
|
||||||
**attr.asdict(
|
attr.asdict(
|
||||||
entity_entry, filter=lambda attr, value: attr.name != "entity_id"
|
entity_entry, filter=lambda attr, value: attr.name != "entity_id"
|
||||||
),
|
),
|
||||||
"state": state_dict,
|
TO_REDACT,
|
||||||
},
|
),
|
||||||
TO_REDACT,
|
"state": state_dict,
|
||||||
)
|
}
|
||||||
data["device"]["entities"][entity_entry.entity_id] = entity_dict
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user