mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add diagnostics for Ohme (#140833)
This commit is contained in:
parent
776495dfa2
commit
74992344d5
24
homeassistant/components/ohme/diagnostics.py
Normal file
24
homeassistant/components/ohme/diagnostics.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""Provides diagnostics for Ohme."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import OhmeConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: OhmeConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for Ohme."""
|
||||
coordinators = config_entry.runtime_data
|
||||
client = coordinators.charge_session_coordinator.client
|
||||
|
||||
return {
|
||||
"device_info": client.device_info,
|
||||
"vehicles": client.vehicles,
|
||||
"ct_connected": client.ct_connected,
|
||||
"cap_available": client.cap_available,
|
||||
}
|
@ -39,7 +39,7 @@ rules:
|
||||
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery:
|
||||
status: exempt
|
||||
comment: |
|
||||
|
16
tests/components/ohme/snapshots/test_diagnostics.ambr
Normal file
16
tests/components/ohme/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,16 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'cap_available': True,
|
||||
'ct_connected': True,
|
||||
'device_info': dict({
|
||||
'model': 'Home Pro',
|
||||
'name': 'Ohme Home Pro',
|
||||
'sw_version': 'v2.65',
|
||||
}),
|
||||
'vehicles': list([
|
||||
'Nissan Leaf',
|
||||
'Tesla Model 3',
|
||||
]),
|
||||
})
|
||||
# ---
|
28
tests/components/ohme/test_diagnostics.py
Normal file
28
tests/components/ohme/test_diagnostics.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""Tests for the diagnostics data provided by the Ohme integration."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from syrupy 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_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_client: MagicMock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
|
||||
== snapshot
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user