-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add diagnostics support for WMS WebControl pro (#126077)
- Loading branch information
Showing
6 changed files
with
293 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 240 additions & 0 deletions
240
tests/components/wmspro/snapshots/test_diagnostics.ambr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}), | ||
}), | ||
}), | ||
}) | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |