1 """Diagnostics support for ESPHome."""
3 from __future__
import annotations
12 from .
import CONF_NOISE_PSK
13 from .dashboard
import async_get_dashboard
14 from .entry_data
import ESPHomeConfigEntry
16 CONF_MAC_ADDRESS =
"mac_address"
18 REDACT_KEYS = {CONF_NOISE_PSK, CONF_PASSWORD, CONF_MAC_ADDRESS}
22 hass: HomeAssistant, config_entry: ESPHomeConfigEntry
24 """Return diagnostics for a config entry."""
25 diag: dict[str, Any] = {}
27 diag[
"config"] = config_entry.as_dict()
29 entry_data = config_entry.runtime_data
31 if (storage_data := await entry_data.store.async_load())
is not None:
32 diag[
"storage_data"] = storage_data
35 config_entry.unique_id
37 and (bluetooth_device := entry_data.bluetooth_device)
40 "connections_free": bluetooth_device.ble_connections_free,
41 "connections_limit": bluetooth_device.ble_connections_limit,
42 "available": bluetooth_device.available,
43 "scanner": await scanner.async_diagnostics(),
47 diag[
"dashboard"] = dashboard.addon_slug
BaseHaScanner|None async_scanner_by_source(HomeAssistant hass, str source)
dict async_redact_data(Mapping data, Iterable[Any] to_redact)
ESPHomeDashboardCoordinator|None async_get_dashboard(HomeAssistant hass)
dict[str, Any] async_get_config_entry_diagnostics(HomeAssistant hass, ESPHomeConfigEntry config_entry)