Add diagnostics platform to ista EcoTrend (#143428)

This commit is contained in:
Manu 2025-04-22 14:12:43 +02:00 committed by GitHub
parent 9249ea0dbb
commit aedd60e74f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 266 additions and 1 deletions

View File

@ -0,0 +1,33 @@
"""Diagnostics platform for ista EcoTrend integration."""
from __future__ import annotations
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.core import HomeAssistant
from .coordinator import IstaConfigEntry
TO_REDACT = {
"firstName",
"lastName",
"street",
"houseNumber",
"documentNumber",
"postalCode",
"city",
"propertyNumber",
"idAtCustomerUser",
}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: IstaConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
return {
"details": async_redact_data(config_entry.runtime_data.details, TO_REDACT),
"data": async_redact_data(config_entry.runtime_data.data, TO_REDACT),
}

View File

@ -43,7 +43,7 @@ rules:
# Gold
devices: done
diagnostics: todo
diagnostics: done
discovery-update-info:
status: exempt
comment: The integration is a web service, there are no discoverable devices.

View File

@ -0,0 +1,205 @@
# serializer version: 1
# name: test_diagnostics
dict({
'data': dict({
'26e93f1a-c828-11ea-87d0-0242ac130003': dict({
'consumptionUnitId': '26e93f1a-c828-11ea-87d0-0242ac130003',
'consumptions': list([
dict({
'date': dict({
'month': 5,
'year': 2024,
}),
'readings': list([
dict({
'additionalValue': '38,0',
'type': 'heating',
'value': '35',
}),
dict({
'additionalValue': '57,0',
'type': 'warmwater',
'value': '1,0',
}),
dict({
'type': 'water',
'value': '5,0',
}),
]),
}),
dict({
'date': dict({
'month': 4,
'year': 2024,
}),
'readings': list([
dict({
'additionalValue': '113,0',
'type': 'heating',
'value': '104',
}),
dict({
'additionalValue': '61,1',
'type': 'warmwater',
'value': '1,1',
}),
dict({
'type': 'water',
'value': '6,8',
}),
]),
}),
]),
'costs': list([
dict({
'costsByEnergyType': list([
dict({
'type': 'heating',
'value': 21,
}),
dict({
'type': 'warmwater',
'value': 7,
}),
dict({
'type': 'water',
'value': 3,
}),
]),
'date': dict({
'month': 5,
'year': 2024,
}),
}),
dict({
'costsByEnergyType': list([
dict({
'type': 'heating',
'value': 62,
}),
dict({
'type': 'warmwater',
'value': 7,
}),
dict({
'type': 'water',
'value': 2,
}),
]),
'date': dict({
'month': 4,
'year': 2024,
}),
}),
]),
}),
'eaf5c5c8-889f-4a3c-b68c-e9a676505762': dict({
'consumptionUnitId': 'eaf5c5c8-889f-4a3c-b68c-e9a676505762',
'consumptions': list([
dict({
'date': dict({
'month': 5,
'year': 2024,
}),
'readings': list([
dict({
'additionalValue': '38,0',
'type': 'heating',
'value': '35',
}),
dict({
'additionalValue': '57,0',
'type': 'warmwater',
'value': '1,0',
}),
dict({
'type': 'water',
'value': '5,0',
}),
]),
}),
dict({
'date': dict({
'month': 4,
'year': 2024,
}),
'readings': list([
dict({
'additionalValue': '113,0',
'type': 'heating',
'value': '104',
}),
dict({
'additionalValue': '61,1',
'type': 'warmwater',
'value': '1,1',
}),
dict({
'type': 'water',
'value': '6,8',
}),
]),
}),
]),
'costs': list([
dict({
'costsByEnergyType': list([
dict({
'type': 'heating',
'value': 21,
}),
dict({
'type': 'warmwater',
'value': 7,
}),
dict({
'type': 'water',
'value': 3,
}),
]),
'date': dict({
'month': 5,
'year': 2024,
}),
}),
dict({
'costsByEnergyType': list([
dict({
'type': 'heating',
'value': 62,
}),
dict({
'type': 'warmwater',
'value': 7,
}),
dict({
'type': 'water',
'value': 2,
}),
]),
'date': dict({
'month': 4,
'year': 2024,
}),
}),
]),
}),
}),
'details': dict({
'26e93f1a-c828-11ea-87d0-0242ac130003': dict({
'address': dict({
'houseNumber': '**REDACTED**',
'street': '**REDACTED**',
}),
'id': '26e93f1a-c828-11ea-87d0-0242ac130003',
}),
'eaf5c5c8-889f-4a3c-b68c-e9a676505762': dict({
'address': dict({
'houseNumber': '**REDACTED**',
'street': '**REDACTED**',
}),
'id': 'eaf5c5c8-889f-4a3c-b68c-e9a676505762',
}),
}),
})
# ---

View File

@ -0,0 +1,27 @@
"""Tests for ista EcoTrend diagnostics platform ."""
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
@pytest.mark.usefixtures("mock_ista")
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
ista_config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics."""
ista_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(ista_config_entry.entry_id)
await hass.async_block_till_done()
assert (
await get_diagnostics_for_config_entry(hass, hass_client, ista_config_entry)
== snapshot
)