d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Diagnostics support for Indevolt integration."""
|
|
|
|
from typing import Any
|
|
|
|
from indevolt_api import IndevoltBattery, IndevoltSystem
|
|
|
|
from homeassistant.components.diagnostics import async_redact_data
|
|
from homeassistant.const import CONF_HOST
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import CONF_SERIAL_NUMBER
|
|
from .coordinator import IndevoltConfigEntry
|
|
|
|
# Redact sensitive information from diagnostics (host and serial numbers)
|
|
TO_REDACT = {
|
|
CONF_HOST,
|
|
CONF_SERIAL_NUMBER,
|
|
IndevoltSystem.SERIAL_NUMBER,
|
|
IndevoltBattery.MAIN_SERIAL_NUMBER,
|
|
IndevoltBattery.PACK_1_SERIAL_NUMBER,
|
|
IndevoltBattery.PACK_2_SERIAL_NUMBER,
|
|
IndevoltBattery.PACK_3_SERIAL_NUMBER,
|
|
IndevoltBattery.PACK_4_SERIAL_NUMBER,
|
|
IndevoltBattery.PACK_5_SERIAL_NUMBER,
|
|
}
|
|
|
|
|
|
async def async_get_config_entry_diagnostics(
|
|
hass: HomeAssistant, entry: IndevoltConfigEntry
|
|
) -> dict[str, Any]:
|
|
"""Return diagnostics for a config entry."""
|
|
coordinator = entry.runtime_data
|
|
|
|
device_info = {
|
|
"model": coordinator.device_model,
|
|
"generation": coordinator.generation,
|
|
"serial_number": coordinator.serial_number,
|
|
"firmware_version": coordinator.firmware_version,
|
|
}
|
|
|
|
return {
|
|
"entry_data": async_redact_data(entry.data, TO_REDACT),
|
|
"device": async_redact_data(device_info, TO_REDACT),
|
|
"coordinator_data": async_redact_data(coordinator.data, TO_REDACT),
|
|
"last_update_success": coordinator.last_update_success,
|
|
}
|