mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 08:26:41 +01:00
Add diagnostics to Zinvolt (#165623)
This commit is contained in:
committed by
GitHub
parent
1a9da26286
commit
bac370e775
23
homeassistant/components/zinvolt/diagnostics.py
Normal file
23
homeassistant/components/zinvolt/diagnostics.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Diagnostics support for Zinvolt."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import ZinvoltConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ZinvoltConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
return {
|
||||
"coordinators": [
|
||||
{
|
||||
coordinator.battery.identifier: coordinator.data.to_dict(),
|
||||
}
|
||||
for coordinator in entry.runtime_data.values()
|
||||
],
|
||||
}
|
||||
@@ -41,7 +41,7 @@ rules:
|
||||
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery-update-info: todo
|
||||
discovery: todo
|
||||
docs-data-update: todo
|
||||
|
||||
34
tests/components/zinvolt/snapshots/test_diagnostics.ambr
Normal file
34
tests/components/zinvolt/snapshots/test_diagnostics.ambr
Normal file
@@ -0,0 +1,34 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'coordinators': list([
|
||||
dict({
|
||||
'a125ef17-6bdf-45ad-b106-ce54e95e4634': dict({
|
||||
'current_power': dict({
|
||||
'is_dormant': False,
|
||||
'max_power': 800,
|
||||
'on_grid': True,
|
||||
'online_status': 'ONLINE',
|
||||
'output_current': 4,
|
||||
'photovoltaic_power': 0,
|
||||
'power_socket_output': -19,
|
||||
'state_of_charge': 100.0,
|
||||
}),
|
||||
'global_settings': dict({
|
||||
'battery_lower_threshold': 10,
|
||||
'battery_upper_threshold': 100,
|
||||
'max_output': 800,
|
||||
'max_output_limit': 800,
|
||||
'max_output_unlocked': False,
|
||||
'maximum_charge_power': 800,
|
||||
'standby_time': 60,
|
||||
}),
|
||||
'name': 'ZVG011025120088',
|
||||
'online_status': 'ONLINE',
|
||||
'serial_number': 'ZVG011025120088',
|
||||
'smart_mode': 'CHARGED',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
30
tests/components/zinvolt/test_diagnostics.py
Normal file
30
tests/components/zinvolt/test_diagnostics.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Tests for Zinvolt diagnostics."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
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_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_zinvolt_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
result = await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_config_entry
|
||||
)
|
||||
|
||||
assert result == snapshot
|
||||
Reference in New Issue
Block a user