1 """Diagnostics support for Powerview Hunter Douglas."""
3 from __future__
import annotations
5 from dataclasses
import asdict
16 from .const
import REDACT_HUB_ADDRESS, REDACT_MAC_ADDRESS, REDACT_SERIAL_NUMBER
17 from .model
import PowerviewConfigEntry
24 ATTR_CONFIGURATION_URL,
29 hass: HomeAssistant, entry: PowerviewConfigEntry
31 """Return diagnostics for a config entry."""
33 device_registry = dr.async_get(hass)
37 for device
in dr.async_entries_for_config_entry(
38 device_registry, entry.entry_id
46 hass: HomeAssistant, entry: PowerviewConfigEntry, device: DeviceEntry
48 """Return diagnostics for a device entry."""
54 shade_data = data[
"shade_data"]
55 for shade
in shade_data:
56 if shade_data[shade][
"name_unicode"] == device.name:
57 data[
"shade_data"] = shade_data[shade]
64 entry: PowerviewConfigEntry,
66 """Return diagnostics for a config entry."""
67 pv_entry = entry.runtime_data
68 shade_data = pv_entry.coordinator.data.get_all_raw_data()
70 return {
"hub_info": hub_info,
"shade_data": shade_data}
75 """Represent a Powerview device as a dictionary."""
78 entity_registry = er.async_get(hass)
82 entities: list[dict[str, Any]] = data[
"entities"]
84 entries = er.async_entries_for_device(
87 include_disabled_entities=
True,
90 for entity_entry
in entries:
91 state = hass.states.get(entity_entry.entity_id)
94 state_dict =
dict(state.as_dict())
95 state_dict.pop(
"context",
None)
97 entity = attr.asdict(entity_entry)
98 entity[
"state"] = state_dict
99 entities.append(entity)
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
dict[str, Any] async_get_device_diagnostics(HomeAssistant hass, PowerviewConfigEntry entry, DeviceEntry device)
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, PowerviewConfigEntry entry)
dict[str, Any] _async_get_diagnostics(HomeAssistant hass, PowerviewConfigEntry entry)
dict[str, Any] _async_device_as_dict(HomeAssistant hass, DeviceEntry device)