Migrate ESPHome to use entry.runtime_data (#120402)

This commit is contained in:
J. Nick Koston 2024-06-25 13:10:09 +02:00 committed by GitHub
parent 7453b7df63
commit fccb7ea1f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 93 additions and 79 deletions

View file

@ -6,12 +6,12 @@ from typing import Any
from homeassistant.components.bluetooth import async_scanner_by_source
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD
from homeassistant.core import HomeAssistant
from . import CONF_NOISE_PSK, DomainData
from . import CONF_NOISE_PSK
from .dashboard import async_get_dashboard
from .entry_data import ESPHomeConfigEntry
CONF_MAC_ADDRESS = "mac_address"
@ -19,14 +19,14 @@ REDACT_KEYS = {CONF_NOISE_PSK, CONF_PASSWORD, CONF_MAC_ADDRESS}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: ESPHomeConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
diag: dict[str, Any] = {}
diag["config"] = config_entry.as_dict()
entry_data = DomainData.get(hass).get_entry_data(config_entry)
entry_data = config_entry.runtime_data
if (storage_data := await entry_data.store.async_load()) is not None:
diag["storage_data"] = storage_data