Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion homeassistant/components/overkiz/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ async def async_get_device_diagnostics(
data["execution_history"] = [
repr(execution)
for execution in await client.get_execution_history()
if any(command.device_url == device_url for command in execution.commands)
if any(
command.device_url.split("#", 1)[0] == device_url.split("#", 1)[0]
for command in execution.commands
)
]

return data
46 changes: 46 additions & 0 deletions tests/components/overkiz/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,49 @@ async def test_device_diagnostics(
)
== snapshot
)


async def test_device_diagnostics_execution_history_subsystem(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
init_integration: MockConfigEntry,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test execution history matching ignores subsystem suffix."""

diagnostic_data = await async_load_json_object_fixture(
hass, "setup_tahoma_switch.json", DOMAIN
)

device = device_registry.async_get_device(
identifiers={(DOMAIN, "rts://****-****-6867/16756006")}
)
assert device is not None

class _FakeCommand:
def __init__(self, device_url: str) -> None:
self.device_url = device_url

class _FakeExecution:
def __init__(self, name: str, device_urls: list[str]) -> None:
self.name = name
self.commands = [_FakeCommand(device_url) for device_url in device_urls]

def __repr__(self) -> str:
return f"Execution({self.name})"

execution_history = [
_FakeExecution("matching", ["rts://****-****-6867/16756006#2"]),
_FakeExecution("other", ["rts://****-****-6867/other_device"]),
]
Comment on lines +100 to +103
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test only covers the case where the device URL has no subsystem suffix but the command URL does. Consider adding test cases for:

  1. Device URL with subsystem matching command URL without subsystem
  2. Device URL with subsystem matching command URL with a different subsystem
  3. Multiple commands with different subsystem suffixes for the same base device

These additional test cases would ensure the bidirectional matching works correctly and cover edge cases where both URLs have subsystems.

Copilot uses AI. Check for mistakes.

with patch.multiple(
"pyoverkiz.client.OverkizClient",
get_diagnostic_data=AsyncMock(return_value=diagnostic_data),
get_execution_history=AsyncMock(return_value=execution_history),
):
diagnostics = await get_diagnostics_for_device(
hass, hass_client, init_integration, device
)

assert diagnostics["execution_history"] == ["Execution(matching)"]
Loading