mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add diagnostics platform to IronOS integration (#136040)
This commit is contained in:
parent
85f10cf60a
commit
9e37c0dc8f
25
homeassistant/components/iron_os/diagnostics.py
Normal file
25
homeassistant/components/iron_os/diagnostics.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""Diagnostics platform for IronOS integration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.const import CONF_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import IronOSConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: IronOSConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
|
||||
return {
|
||||
"config_entry_data": {
|
||||
CONF_ADDRESS: config_entry.unique_id,
|
||||
},
|
||||
"device_info": config_entry.runtime_data.live_data.device_info,
|
||||
"live_data": config_entry.runtime_data.live_data.data,
|
||||
"settings_data": config_entry.runtime_data.settings.data,
|
||||
}
|
@ -43,7 +43,7 @@ rules:
|
||||
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: Device is not connected to an ip network. Other information from discovery is immutable and does not require updating.
|
||||
|
18
tests/components/iron_os/snapshots/test_diagnostics.ambr
Normal file
18
tests/components/iron_os/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,18 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'config_entry_data': dict({
|
||||
'address': 'c0:ff:ee:c0:ff:ee',
|
||||
}),
|
||||
'device_info': dict({
|
||||
'__type': "<class 'pynecil.types.DeviceInfoResponse'>",
|
||||
'repr': "DeviceInfoResponse(build='v2.22', device_id='c0ffeeC0', address='c0:ff:ee:c0:ff:ee', device_sn='0000c0ffeec0ffee', name='Pinecil-C0FFEEE', is_synced=False)",
|
||||
}),
|
||||
'live_data': dict({
|
||||
'__type': "<class 'pynecil.types.LiveDataResponse'>",
|
||||
'repr': 'LiveDataResponse(live_temp=298, setpoint_temp=300, dc_voltage=20.6, handle_temp=36.3, pwm_level=41, power_src=<PowerSource.PD: 3>, tip_resistance=6.2, uptime=1671, movement_time=10000, max_tip_temp_ability=460, tip_voltage=2212, hall_sensor=0, operating_mode=<OperatingMode.SOLDERING: 1>, estimated_power=24.8)',
|
||||
}),
|
||||
'settings_data': dict({
|
||||
}),
|
||||
})
|
||||
# ---
|
29
tests/components/iron_os/test_diagnostics.py
Normal file
29
tests/components/iron_os/test_diagnostics.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Tests for IronOS diagnostics."""
|
||||
|
||||
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(
|
||||
"entity_registry_enabled_by_default", "mock_pynecil", "ble_device"
|
||||
)
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
config_entry: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||
== snapshot
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user