Skip to content

Commit 6cae182

Browse files
authored
Fix execution history matching to ignore subsystem suffix in diagnostics in Overkiz (#160218)
1 parent 8d8046d commit 6cae182

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

homeassistant/components/overkiz/diagnostics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ async def async_get_device_diagnostics(
6161
data["execution_history"] = [
6262
repr(execution)
6363
for execution in await client.get_execution_history()
64-
if any(command.device_url == device_url for command in execution.commands)
64+
if any(
65+
command.device_url.split("#", 1)[0] == device_url.split("#", 1)[0]
66+
for command in execution.commands
67+
)
6568
]
6669

6770
return data

tests/components/overkiz/test_diagnostics.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,49 @@ async def test_device_diagnostics(
6666
)
6767
== snapshot
6868
)
69+
70+
71+
async def test_device_diagnostics_execution_history_subsystem(
72+
hass: HomeAssistant,
73+
hass_client: ClientSessionGenerator,
74+
init_integration: MockConfigEntry,
75+
device_registry: dr.DeviceRegistry,
76+
) -> None:
77+
"""Test execution history matching ignores subsystem suffix."""
78+
79+
diagnostic_data = await async_load_json_object_fixture(
80+
hass, "setup_tahoma_switch.json", DOMAIN
81+
)
82+
83+
device = device_registry.async_get_device(
84+
identifiers={(DOMAIN, "rts://****-****-6867/16756006")}
85+
)
86+
assert device is not None
87+
88+
class _FakeCommand:
89+
def __init__(self, device_url: str) -> None:
90+
self.device_url = device_url
91+
92+
class _FakeExecution:
93+
def __init__(self, name: str, device_urls: list[str]) -> None:
94+
self.name = name
95+
self.commands = [_FakeCommand(device_url) for device_url in device_urls]
96+
97+
def __repr__(self) -> str:
98+
return f"Execution({self.name})"
99+
100+
execution_history = [
101+
_FakeExecution("matching", ["rts://****-****-6867/16756006#2"]),
102+
_FakeExecution("other", ["rts://****-****-6867/other_device"]),
103+
]
104+
105+
with patch.multiple(
106+
"pyoverkiz.client.OverkizClient",
107+
get_diagnostic_data=AsyncMock(return_value=diagnostic_data),
108+
get_execution_history=AsyncMock(return_value=execution_history),
109+
):
110+
diagnostics = await get_diagnostics_for_device(
111+
hass, hass_client, init_integration, device
112+
)
113+
114+
assert diagnostics["execution_history"] == ["Execution(matching)"]

0 commit comments

Comments
 (0)