Add support for WiZ diagnostics (#66817)
This commit is contained in:
parent
c4cc6ca0ba
commit
e9ca7c2516
6 changed files with 54 additions and 3 deletions
27
homeassistant/components/wiz/diagnostics.py
Normal file
27
homeassistant/components/wiz/diagnostics.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
"""Diagnostics support for WiZ."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
from .models import WizData
|
||||
|
||||
TO_REDACT = {"roomId", "homeId"}
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
wiz_data: WizData = hass.data[DOMAIN][entry.entry_id]
|
||||
return {
|
||||
"entry": {
|
||||
"title": entry.title,
|
||||
"data": dict(entry.data),
|
||||
},
|
||||
"data": async_redact_data(wiz_data.bulb.diagnostics, TO_REDACT),
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
"dependencies": ["network"],
|
||||
"quality_scale": "platinum",
|
||||
"documentation": "https://www.home-assistant.io/integrations/wiz",
|
||||
"requirements": ["pywizlight==0.5.9"],
|
||||
"requirements": ["pywizlight==0.5.10"],
|
||||
"iot_class": "local_push",
|
||||
"codeowners": ["@sbidy"]
|
||||
}
|
||||
|
|
|
@ -2057,7 +2057,7 @@ pywemo==0.7.0
|
|||
pywilight==0.0.70
|
||||
|
||||
# homeassistant.components.wiz
|
||||
pywizlight==0.5.9
|
||||
pywizlight==0.5.10
|
||||
|
||||
# homeassistant.components.xeoma
|
||||
pyxeoma==1.4.1
|
||||
|
|
|
@ -1288,7 +1288,7 @@ pywemo==0.7.0
|
|||
pywilight==0.0.70
|
||||
|
||||
# homeassistant.components.wiz
|
||||
pywizlight==0.5.9
|
||||
pywizlight==0.5.10
|
||||
|
||||
# homeassistant.components.zerproc
|
||||
pyzerproc==0.4.8
|
||||
|
|
|
@ -171,6 +171,11 @@ def _mocked_wizlight(device, extended_white_range, bulb_type) -> wizlight:
|
|||
bulb.start_push = AsyncMock(side_effect=_save_setup_callback)
|
||||
bulb.async_close = AsyncMock()
|
||||
bulb.set_speed = AsyncMock()
|
||||
bulb.diagnostics = {
|
||||
"mocked": "mocked",
|
||||
"roomId": 123,
|
||||
"homeId": 34,
|
||||
}
|
||||
bulb.state = FAKE_STATE
|
||||
bulb.mac = FAKE_MAC
|
||||
bulb.bulbtype = bulb_type or FAKE_DIMMABLE_BULB
|
||||
|
|
19
tests/components/wiz/test_diagnostics.py
Normal file
19
tests/components/wiz/test_diagnostics.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
"""Test WiZ diagnostics."""
|
||||
from . import async_setup_integration
|
||||
|
||||
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 = await async_setup_integration(hass)
|
||||
diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
||||
assert diag == {
|
||||
"data": {
|
||||
"homeId": "**REDACTED**",
|
||||
"mocked": "mocked",
|
||||
"roomId": "**REDACTED**",
|
||||
},
|
||||
"entry": {"data": {"host": "1.1.1.1"}, "title": "Mock Title"},
|
||||
}
|
Loading…
Add table
Reference in a new issue