mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Add diagnostics to Gree Climate (#189137)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
989374ed40
commit
22db1efbde
@@ -0,0 +1,27 @@
|
||||
"""Diagnostics support for Gree Climate."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import GreeConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: GreeConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
return {
|
||||
"devices": [
|
||||
{
|
||||
"brand": coordinator.device.device_info.brand,
|
||||
"model": coordinator.device.device_info.model,
|
||||
"info_version": coordinator.device.device_info.version,
|
||||
"hid": coordinator.device.hid,
|
||||
"version": coordinator.device.version,
|
||||
"last_update_success": coordinator.last_update_success,
|
||||
"raw_properties": coordinator.data,
|
||||
}
|
||||
for coordinator in entry.runtime_data.coordinators
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'devices': list([
|
||||
dict({
|
||||
'brand': 'gree',
|
||||
'hid': '362001000762+U-CS532AE(LT)V3.31.bin',
|
||||
'info_version': 'V1.2.1',
|
||||
'last_update_success': True,
|
||||
'model': 'gree',
|
||||
'raw_properties': dict({
|
||||
'Lig': 1,
|
||||
'Mod': 1,
|
||||
'Pow': 1,
|
||||
'Quiet': 0,
|
||||
'SetTem': 22,
|
||||
'TemSen': 64,
|
||||
'TemUn': 0,
|
||||
'Tur': 0,
|
||||
'WdSpd': 0,
|
||||
}),
|
||||
'version': '3.31',
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Tests for the Gree Climate diagnostics."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from pytest_homeassistant.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from pytest_homeassistant.typing import ClientSessionGenerator
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .common import async_setup_gree
|
||||
|
||||
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
device: MagicMock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
mock_device = device.return_value
|
||||
mock_device.device_info.brand = "gree"
|
||||
mock_device.device_info.model = "gree"
|
||||
mock_device.device_info.version = "V1.2.1"
|
||||
mock_device.hid = "362001000762+U-CS532AE(LT)V3.31.bin"
|
||||
mock_device.version = "3.31"
|
||||
mock_device.raw_properties = {
|
||||
"Pow": 1,
|
||||
"Mod": 1,
|
||||
"SetTem": 22,
|
||||
"TemSen": 64,
|
||||
"TemUn": 0,
|
||||
"WdSpd": 0,
|
||||
"Lig": 1,
|
||||
"Quiet": 0,
|
||||
"Tur": 0,
|
||||
}
|
||||
|
||||
entry = await async_setup_gree(hass)
|
||||
|
||||
assert await get_diagnostics_for_config_entry(hass, hass_client, entry) == snapshot
|
||||
Reference in New Issue
Block a user