mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Implement TechnoVE diagnostic (#121278)
This commit is contained in:
parent
b5a0e89c03
commit
df9ced9768
23
homeassistant/components/technove/diagnostics.py
Normal file
23
homeassistant/components/technove/diagnostics.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""Diagnostics support for TechnoVE."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict
|
||||
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
|
||||
from .coordinator import TechnoVEDataUpdateCoordinator
|
||||
|
||||
TO_REDACT = {"unique_id", "mac_address"}
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: TechnoVEDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
return async_redact_data(asdict(coordinator.data.info), TO_REDACT)
|
36
tests/components/technove/snapshots/test_diagnostics.ambr
Normal file
36
tests/components/technove/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,36 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'auto_charge': True,
|
||||
'conflict_in_sharing_config': False,
|
||||
'current': 23.75,
|
||||
'energy_session': 12.34,
|
||||
'energy_total': 1234,
|
||||
'high_charge_period_active': False,
|
||||
'in_sharing_mode': False,
|
||||
'is_battery_protected': False,
|
||||
'is_session_active': True,
|
||||
'is_static_ip': False,
|
||||
'is_up_to_date': True,
|
||||
'last_charge': '''
|
||||
1701072080,0,17.39
|
||||
|
||||
''',
|
||||
'mac_address': '**REDACTED**',
|
||||
'max_charge_percentage': 0.9,
|
||||
'max_current': 24,
|
||||
'max_station_current': 32,
|
||||
'name': 'TechnoVE Station',
|
||||
'network_ssid': 'Connecting...',
|
||||
'normal_period_active': False,
|
||||
'rssi': -82,
|
||||
'status': dict({
|
||||
'__type': "<enum 'Status'>",
|
||||
'repr': "<Status.PLUGGED_CHARGING: 'plugged_charging'>",
|
||||
}),
|
||||
'time': 1701000000,
|
||||
'version': '1.82',
|
||||
'voltage_in': 238,
|
||||
'voltage_out': 238,
|
||||
})
|
||||
# ---
|
22
tests/components/technove/test_diagnostics.py
Normal file
22
tests/components/technove/test_diagnostics.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""Tests for TechnoVE diagnostics."""
|
||||
|
||||
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
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
init_integration: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||
== snapshot
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user