Add diagnostics support for WMS WebControl pro (#126077)
This commit is contained in:
parent
adcb541b4b
commit
37cdc6d500
6 changed files with 293 additions and 3 deletions
16
homeassistant/components/wmspro/diagnostics.py
Normal file
16
homeassistant/components/wmspro/diagnostics.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""Diagnostics support for WMS WebControl pro API integration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import WebControlProConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: WebControlProConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
return entry.runtime_data.diag()
|
|
@ -15,5 +15,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/wmspro",
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_polling",
|
||||
"requirements": ["pywmspro==0.1.0"]
|
||||
"requirements": ["pywmspro==0.2.0"]
|
||||
}
|
||||
|
|
|
@ -2471,7 +2471,7 @@ pywilight==0.0.74
|
|||
pywizlight==0.5.14
|
||||
|
||||
# homeassistant.components.wmspro
|
||||
pywmspro==0.1.0
|
||||
pywmspro==0.2.0
|
||||
|
||||
# homeassistant.components.ws66i
|
||||
pyws66i==1.1
|
||||
|
|
|
@ -1971,7 +1971,7 @@ pywilight==0.0.74
|
|||
pywizlight==0.5.14
|
||||
|
||||
# homeassistant.components.wmspro
|
||||
pywmspro==0.1.0
|
||||
pywmspro==0.2.0
|
||||
|
||||
# homeassistant.components.ws66i
|
||||
pyws66i==1.1
|
||||
|
|
240
tests/components/wmspro/snapshots/test_diagnostics.ambr
Normal file
240
tests/components/wmspro/snapshots/test_diagnostics.ambr
Normal file
|
@ -0,0 +1,240 @@
|
|||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'config': dict({
|
||||
'command': 'getConfiguration',
|
||||
'destinations': list([
|
||||
dict({
|
||||
'actions': list([
|
||||
dict({
|
||||
'actionDescription': 0,
|
||||
'actionType': 0,
|
||||
'id': 0,
|
||||
'maxValue': 100,
|
||||
'minValue': 0,
|
||||
}),
|
||||
dict({
|
||||
'actionDescription': 12,
|
||||
'actionType': 6,
|
||||
'id': 16,
|
||||
}),
|
||||
dict({
|
||||
'actionDescription': 13,
|
||||
'actionType': 8,
|
||||
'id': 22,
|
||||
}),
|
||||
]),
|
||||
'animationType': 1,
|
||||
'id': 58717,
|
||||
'names': list([
|
||||
'Markise',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
]),
|
||||
}),
|
||||
dict({
|
||||
'actions': list([
|
||||
dict({
|
||||
'actionDescription': 8,
|
||||
'actionType': 0,
|
||||
'id': 0,
|
||||
'maxValue': 100,
|
||||
'minValue': 0,
|
||||
}),
|
||||
dict({
|
||||
'actionDescription': 12,
|
||||
'actionType': 6,
|
||||
'id': 17,
|
||||
}),
|
||||
dict({
|
||||
'actionDescription': 6,
|
||||
'actionType': 4,
|
||||
'id': 20,
|
||||
}),
|
||||
dict({
|
||||
'actionDescription': 13,
|
||||
'actionType': 8,
|
||||
'id': 22,
|
||||
}),
|
||||
]),
|
||||
'animationType': 6,
|
||||
'id': 97358,
|
||||
'names': list([
|
||||
'Licht',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
'protocolVersion': '1.0.0',
|
||||
'rooms': list([
|
||||
dict({
|
||||
'destinations': list([
|
||||
58717,
|
||||
97358,
|
||||
]),
|
||||
'id': 19239,
|
||||
'name': 'Terrasse',
|
||||
'scenes': list([
|
||||
687471,
|
||||
765095,
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
'scenes': list([
|
||||
dict({
|
||||
'id': 687471,
|
||||
'names': list([
|
||||
'Licht an',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
]),
|
||||
}),
|
||||
dict({
|
||||
'id': 765095,
|
||||
'names': list([
|
||||
'Licht aus',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
'dests': dict({
|
||||
'58717': dict({
|
||||
'actions': dict({
|
||||
'0': dict({
|
||||
'actionDescription': 'AwningDrive',
|
||||
'actionType': 'Percentage',
|
||||
'attrs': dict({
|
||||
'maxValue': 100,
|
||||
'minValue': 0,
|
||||
}),
|
||||
'id': 0,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
'16': dict({
|
||||
'actionDescription': 'ManualCommand',
|
||||
'actionType': 'Stop',
|
||||
'attrs': dict({
|
||||
}),
|
||||
'id': 16,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
'22': dict({
|
||||
'actionDescription': 'Identify',
|
||||
'actionType': 'Identify',
|
||||
'attrs': dict({
|
||||
}),
|
||||
'id': 22,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'animationType': 'Awning',
|
||||
'available': True,
|
||||
'blocking': None,
|
||||
'drivingCause': 'Unknown',
|
||||
'heartbeatError': None,
|
||||
'id': 58717,
|
||||
'name': 'Markise',
|
||||
'room': dict({
|
||||
'19239': 'Terrasse',
|
||||
}),
|
||||
'status': dict({
|
||||
}),
|
||||
}),
|
||||
'97358': dict({
|
||||
'actions': dict({
|
||||
'0': dict({
|
||||
'actionDescription': 'LightDimming',
|
||||
'actionType': 'Percentage',
|
||||
'attrs': dict({
|
||||
'maxValue': 100,
|
||||
'minValue': 0,
|
||||
}),
|
||||
'id': 0,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
'17': dict({
|
||||
'actionDescription': 'ManualCommand',
|
||||
'actionType': 'Stop',
|
||||
'attrs': dict({
|
||||
}),
|
||||
'id': 17,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
'20': dict({
|
||||
'actionDescription': 'LightSwitch',
|
||||
'actionType': 'Switch',
|
||||
'attrs': dict({
|
||||
}),
|
||||
'id': 20,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
'22': dict({
|
||||
'actionDescription': 'Identify',
|
||||
'actionType': 'Identify',
|
||||
'attrs': dict({
|
||||
}),
|
||||
'id': 22,
|
||||
'params': dict({
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'animationType': 'Dimmer',
|
||||
'available': True,
|
||||
'blocking': None,
|
||||
'drivingCause': 'Unknown',
|
||||
'heartbeatError': None,
|
||||
'id': 97358,
|
||||
'name': 'Licht',
|
||||
'room': dict({
|
||||
'19239': 'Terrasse',
|
||||
}),
|
||||
'status': dict({
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'host': 'webcontrol',
|
||||
'rooms': dict({
|
||||
'19239': dict({
|
||||
'destinations': dict({
|
||||
'58717': 'Markise',
|
||||
'97358': 'Licht',
|
||||
}),
|
||||
'id': 19239,
|
||||
'name': 'Terrasse',
|
||||
'scenes': dict({
|
||||
'687471': 'Licht an',
|
||||
'765095': 'Licht aus',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
'scenes': dict({
|
||||
'687471': dict({
|
||||
'id': 687471,
|
||||
'name': 'Licht an',
|
||||
'room': dict({
|
||||
'19239': 'Terrasse',
|
||||
}),
|
||||
}),
|
||||
'765095': dict({
|
||||
'id': 765095,
|
||||
'name': 'Licht aus',
|
||||
'room': dict({
|
||||
'19239': 'Terrasse',
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
# ---
|
34
tests/components/wmspro/test_diagnostics.py
Normal file
34
tests/components/wmspro/test_diagnostics.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""Test the wmspro diagnostics."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import setup_config_entry
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_hub_ping: AsyncMock,
|
||||
mock_hub_configuration_prod: AsyncMock,
|
||||
mock_dest_refresh: AsyncMock,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test that a config entry can be loaded with DeviceConfig."""
|
||||
assert await setup_config_entry(hass, mock_config_entry)
|
||||
assert len(mock_hub_ping.mock_calls) == 1
|
||||
assert len(mock_hub_configuration_prod.mock_calls) == 1
|
||||
assert len(mock_dest_refresh.mock_calls) == 2
|
||||
|
||||
result = await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_config_entry
|
||||
)
|
||||
assert result == snapshot
|
Loading…
Add table
Reference in a new issue