mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Add diagnostics to Gree Infrared (#187712)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Diagnostics platform for the Gree Infrared integration."""
|
||||
|
||||
from dataclasses import asdict
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import GreeIrConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: GreeIrConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
return {
|
||||
"entry_data": dict(entry.data),
|
||||
"ac_state": {
|
||||
key: value.name.lower() if isinstance(value, Enum) else value
|
||||
for key, value in asdict(entry.runtime_data.ac_state).items()
|
||||
},
|
||||
}
|
||||
@@ -58,7 +58,7 @@ rules:
|
||||
test-coverage: done
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: |
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'ac_state': dict({
|
||||
'blow': False,
|
||||
'display': True,
|
||||
'fan': 'auto',
|
||||
'mode': 'cool',
|
||||
'power': False,
|
||||
'swing_h': False,
|
||||
'swing_v': False,
|
||||
'temperature': 16,
|
||||
'turbo': False,
|
||||
}),
|
||||
'entry_data': dict({
|
||||
'hvac_modes': list([
|
||||
'cool',
|
||||
'dry',
|
||||
]),
|
||||
'infrared_emitter_entity_id': 'infrared.test_ir_emitter',
|
||||
'infrared_receiver_entity_id': 'infrared.test_ir_receiver',
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Tests for the Gree Infrared diagnostics platform."""
|
||||
|
||||
from pytest_homeassistant.common import MockConfigEntry
|
||||
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
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
init_integration: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||
== snapshot
|
||||
)
|
||||
Reference in New Issue
Block a user