mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add diagnostics support to flux_led (#67012)
This commit is contained in:
parent
a51d9012ad
commit
d554a82875
24
homeassistant/components/flux_led/diagnostics.py
Normal file
24
homeassistant/components/flux_led/diagnostics.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""Diagnostics support for flux_led."""
|
||||||
|
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 FluxLedUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_config_entry_diagnostics(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""Return diagnostics for a config entry."""
|
||||||
|
coordinator: FluxLedUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
return {
|
||||||
|
"entry": {
|
||||||
|
"title": entry.title,
|
||||||
|
"data": dict(entry.data),
|
||||||
|
},
|
||||||
|
"data": coordinator.device.diagnostics,
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"dependencies": ["network"],
|
"dependencies": ["network"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/flux_led",
|
"documentation": "https://www.home-assistant.io/integrations/flux_led",
|
||||||
"requirements": ["flux_led==0.28.26"],
|
"requirements": ["flux_led==0.28.27"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"codeowners": ["@icemanch", "@bdraco"],
|
"codeowners": ["@icemanch", "@bdraco"],
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
|
@ -679,7 +679,7 @@ fjaraskupan==1.0.2
|
|||||||
flipr-api==1.4.1
|
flipr-api==1.4.1
|
||||||
|
|
||||||
# homeassistant.components.flux_led
|
# homeassistant.components.flux_led
|
||||||
flux_led==0.28.26
|
flux_led==0.28.27
|
||||||
|
|
||||||
# homeassistant.components.homekit
|
# homeassistant.components.homekit
|
||||||
fnvhash==0.1.0
|
fnvhash==0.1.0
|
||||||
|
@ -434,7 +434,7 @@ fjaraskupan==1.0.2
|
|||||||
flipr-api==1.4.1
|
flipr-api==1.4.1
|
||||||
|
|
||||||
# homeassistant.components.flux_led
|
# homeassistant.components.flux_led
|
||||||
flux_led==0.28.26
|
flux_led==0.28.27
|
||||||
|
|
||||||
# homeassistant.components.homekit
|
# homeassistant.components.homekit
|
||||||
fnvhash==0.1.0
|
fnvhash==0.1.0
|
||||||
|
@ -110,6 +110,7 @@ def _mocked_bulb() -> AIOWifiLedBulb:
|
|||||||
bulb.paired_remotes = 2
|
bulb.paired_remotes = 2
|
||||||
bulb.pixels_per_segment = 300
|
bulb.pixels_per_segment = 300
|
||||||
bulb.segments = 2
|
bulb.segments = 2
|
||||||
|
bulb.diagnostics = {"mock_diag": "mock_diag"}
|
||||||
bulb.music_pixels_per_segment = 150
|
bulb.music_pixels_per_segment = 150
|
||||||
bulb.music_segments = 4
|
bulb.music_segments = 4
|
||||||
bulb.operating_mode = "RGB&W"
|
bulb.operating_mode = "RGB&W"
|
||||||
|
40
tests/components/flux_led/test_diagnostics.py
Normal file
40
tests/components/flux_led/test_diagnostics.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
"""Test flux_led diagnostics."""
|
||||||
|
from homeassistant.components.flux_led.const import DOMAIN
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
_mock_config_entry_for_bulb,
|
||||||
|
_mocked_bulb,
|
||||||
|
_patch_discovery,
|
||||||
|
_patch_wifibulb,
|
||||||
|
)
|
||||||
|
|
||||||
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
|
|
||||||
|
|
||||||
|
async def test_diagnostics(hass, hass_client):
|
||||||
|
"""Test generating diagnostics for a config entry."""
|
||||||
|
entry = _mock_config_entry_for_bulb(hass)
|
||||||
|
bulb = _mocked_bulb()
|
||||||
|
with _patch_discovery(), _patch_wifibulb(device=bulb):
|
||||||
|
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||||
|
assert diag == {
|
||||||
|
"data": {"mock_diag": "mock_diag"},
|
||||||
|
"entry": {
|
||||||
|
"data": {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"minor_version": 4,
|
||||||
|
"model": "AK001-ZJ2149",
|
||||||
|
"model_description": "Bulb RGBCW",
|
||||||
|
"model_info": "AK001-ZJ2149",
|
||||||
|
"model_num": 53,
|
||||||
|
"name": "Bulb RGBCW DDEEFF",
|
||||||
|
"remote_access_enabled": True,
|
||||||
|
"remote_access_host": "the.cloud",
|
||||||
|
"remote_access_port": 8816,
|
||||||
|
},
|
||||||
|
"title": "Mock Title",
|
||||||
|
},
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user