mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Add diagnostics to SENZ (#156383)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Diagnostics platform for Senz integration."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
TO_REDACT = [
|
||||
"access_token",
|
||||
"refresh_token",
|
||||
]
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
|
||||
raw_data = (
|
||||
[device.raw_data for device in hass.data[DOMAIN][entry.entry_id].data.values()],
|
||||
)
|
||||
|
||||
return {
|
||||
"entry_data": async_redact_data(entry.data, TO_REDACT),
|
||||
"thermostats": raw_data,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics_config_entry
|
||||
dict({
|
||||
'entry_data': dict({
|
||||
'auth_implementation': 'senz',
|
||||
'token': dict({
|
||||
'access_token': '**REDACTED**',
|
||||
'expires_in': 86399,
|
||||
'refresh_token': '**REDACTED**',
|
||||
'token_type': 'Bearer',
|
||||
}),
|
||||
}),
|
||||
'thermostats': list([
|
||||
list([
|
||||
dict({
|
||||
'currentTemperature': 1845,
|
||||
'errorState': None,
|
||||
'holdUntil': None,
|
||||
'isHeating': True,
|
||||
'mode': 5,
|
||||
'name': 'Test room 1',
|
||||
'online': True,
|
||||
'serialNumber': '1001',
|
||||
'setPointTemperature': 1900,
|
||||
}),
|
||||
dict({
|
||||
'currentTemperature': 930,
|
||||
'errorState': None,
|
||||
'holdUntil': None,
|
||||
'isHeating': False,
|
||||
'mode': 1,
|
||||
'name': 'Test room 2',
|
||||
'online': True,
|
||||
'serialNumber': '1002',
|
||||
'setPointTemperature': 600,
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
@@ -0,0 +1,36 @@
|
||||
"""Tests for the diagnostics data provided by the senz integration."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.filters import paths
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics_config_entry(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_senz_client: Generator[MagicMock],
|
||||
mock_config_entry: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics for config entry."""
|
||||
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
result = await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_config_entry
|
||||
)
|
||||
|
||||
assert result == snapshot(
|
||||
exclude=paths(
|
||||
"entry_data.token.expires_at",
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user