mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add diagnostics to ccm15 (#106329)
* Add diagnostics to ccm15 * Update homeassistant/components/ccm15/diagnostics.py Co-authored-by: J. Nick Koston <nick@koston.org> --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
e469c6892b
commit
c7cb508896
35
homeassistant/components/ccm15/diagnostics.py
Normal file
35
homeassistant/components/ccm15/diagnostics.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Diagnostics support for CCM15."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import CCM15Coordinator
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: CCM15Coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
return {
|
||||
str(device_id): {
|
||||
"is_celsius": device.is_celsius,
|
||||
"locked_cool_temperature": device.locked_cool_temperature,
|
||||
"locked_heat_temperature": device.locked_heat_temperature,
|
||||
"locked_ac_mode": device.locked_ac_mode,
|
||||
"error_code": device.error_code,
|
||||
"ac_mode": device.ac_mode,
|
||||
"fan_mode": device.fan_mode,
|
||||
"is_ac_mode_locked": device.is_ac_mode_locked,
|
||||
"temperature_setpoint": device.temperature_setpoint,
|
||||
"fan_locked": device.fan_locked,
|
||||
"is_remote_locked": device.is_remote_locked,
|
||||
"temperature": device.temperature,
|
||||
}
|
||||
for device_id, device in coordinator.data.devices.items()
|
||||
}
|
33
tests/components/ccm15/snapshots/test_diagnostics.ambr
Normal file
33
tests/components/ccm15/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,33 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'0': dict({
|
||||
'ac_mode': 4,
|
||||
'error_code': 0,
|
||||
'fan_locked': False,
|
||||
'fan_mode': 5,
|
||||
'is_ac_mode_locked': False,
|
||||
'is_celsius': True,
|
||||
'is_remote_locked': False,
|
||||
'locked_ac_mode': 0,
|
||||
'locked_cool_temperature': 0,
|
||||
'locked_heat_temperature': 0,
|
||||
'temperature': 27,
|
||||
'temperature_setpoint': 23,
|
||||
}),
|
||||
'1': dict({
|
||||
'ac_mode': 0,
|
||||
'error_code': 0,
|
||||
'fan_locked': False,
|
||||
'fan_mode': 2,
|
||||
'is_ac_mode_locked': False,
|
||||
'is_celsius': True,
|
||||
'is_remote_locked': False,
|
||||
'locked_ac_mode': 0,
|
||||
'locked_cool_temperature': 0,
|
||||
'locked_heat_temperature': 0,
|
||||
'temperature': 26,
|
||||
'temperature_setpoint': 24,
|
||||
}),
|
||||
})
|
||||
# ---
|
37
tests/components/ccm15/test_diagnostics.py
Normal file
37
tests/components/ccm15/test_diagnostics.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""Test CCM15 diagnostics."""
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.ccm15.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
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_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
ccm15_device: AsyncMock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="1.1.1.1",
|
||||
data={
|
||||
CONF_HOST: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert result == snapshot
|
Loading…
x
Reference in New Issue
Block a user