Add Airzone diagnostics (#69362)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
521579fc6a
commit
0c2acdf337
2 changed files with 86 additions and 0 deletions
29
homeassistant/components/airzone/diagnostics.py
Normal file
29
homeassistant/components/airzone/diagnostics.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
"""Support for the Airzone diagnostics."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from aioairzone.const import AZD_MAC
|
||||
|
||||
from homeassistant.components.diagnostics.util import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import AirzoneUpdateCoordinator
|
||||
|
||||
TO_REDACT = [
|
||||
AZD_MAC,
|
||||
]
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: AirzoneUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
return {
|
||||
"info": async_redact_data(config_entry.data, TO_REDACT),
|
||||
"data": async_redact_data(coordinator.data, TO_REDACT),
|
||||
}
|
57
tests/components/airzone/test_diagnostics.py
Normal file
57
tests/components/airzone/test_diagnostics.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
"""The diagnostics tests for the Airzone platform."""
|
||||
|
||||
from aioairzone.const import (
|
||||
AZD_ID,
|
||||
AZD_MASTER,
|
||||
AZD_SYSTEM,
|
||||
AZD_SYSTEMS,
|
||||
AZD_ZONES,
|
||||
AZD_ZONES_NUM,
|
||||
)
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.components.airzone.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .util import CONFIG, async_init_integration
|
||||
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
|
||||
async def test_config_entry_diagnostics(
|
||||
hass: HomeAssistant, hass_client: ClientSession
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
await async_init_integration(hass)
|
||||
assert hass.data[DOMAIN]
|
||||
|
||||
config_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
|
||||
diag = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||
|
||||
assert diag["info"][CONF_HOST] == CONFIG[CONF_HOST]
|
||||
assert diag["info"][CONF_PORT] == CONFIG[CONF_PORT]
|
||||
|
||||
assert diag["data"][AZD_SYSTEMS]["1"][AZD_ID] == 1
|
||||
assert diag["data"][AZD_SYSTEMS]["1"][AZD_ZONES_NUM] == 5
|
||||
|
||||
assert diag["data"][AZD_ZONES]["1:1"][AZD_ID] == 1
|
||||
assert diag["data"][AZD_ZONES]["1:1"][AZD_MASTER] == 1
|
||||
assert diag["data"][AZD_ZONES]["1:1"][AZD_SYSTEM] == 1
|
||||
|
||||
assert diag["data"][AZD_ZONES]["1:2"][AZD_ID] == 2
|
||||
assert diag["data"][AZD_ZONES]["1:2"][AZD_MASTER] == 0
|
||||
assert diag["data"][AZD_ZONES]["1:2"][AZD_SYSTEM] == 1
|
||||
|
||||
assert diag["data"][AZD_ZONES]["1:3"][AZD_ID] == 3
|
||||
assert diag["data"][AZD_ZONES]["1:3"][AZD_MASTER] == 0
|
||||
assert diag["data"][AZD_ZONES]["1:3"][AZD_SYSTEM] == 1
|
||||
|
||||
assert diag["data"][AZD_ZONES]["1:4"][AZD_ID] == 4
|
||||
assert diag["data"][AZD_ZONES]["1:4"][AZD_MASTER] == 0
|
||||
assert diag["data"][AZD_ZONES]["1:4"][AZD_SYSTEM] == 1
|
||||
|
||||
assert diag["data"][AZD_ZONES]["1:5"][AZD_ID] == 5
|
||||
assert diag["data"][AZD_ZONES]["1:5"][AZD_MASTER] == 0
|
||||
assert diag["data"][AZD_ZONES]["1:5"][AZD_SYSTEM] == 1
|
Loading…
Add table
Add a link
Reference in a new issue