Add diagnostics support to Elgato (#64652)
parent
1bf58b37e9
commit
6c54267f57
|
@ -0,0 +1,21 @@
|
|||
"""Diagnostics support for Elgato."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import HomeAssistantElgatoData
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
data: HomeAssistantElgatoData = hass.data[DOMAIN][entry.entry_id]
|
||||
return {
|
||||
"info": data.info.dict(),
|
||||
"state": data.coordinator.data.dict(),
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
"""Tests for the diagnostics data provided by the Elgato integration."""
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSession,
|
||||
init_integration: MockConfigEntry,
|
||||
):
|
||||
"""Test diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, init_integration
|
||||
) == {
|
||||
"info": {
|
||||
"display_name": "Frenck",
|
||||
"firmware_build_number": 192,
|
||||
"firmware_version": "1.0.3",
|
||||
"hardware_board_type": 53,
|
||||
"product_name": "Elgato Key Light",
|
||||
"serial_number": "CN11A1A00001",
|
||||
"features": ["lights"],
|
||||
},
|
||||
"state": {
|
||||
"on": True,
|
||||
"brightness": 21,
|
||||
"hue": None,
|
||||
"saturation": None,
|
||||
"temperature": 297,
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue