diff --git a/homeassistant/components/overkiz/diagnostics.py b/homeassistant/components/overkiz/diagnostics.py index dae0c6c59cf..45c5030a7c7 100644 --- a/homeassistant/components/overkiz/diagnostics.py +++ b/homeassistant/components/overkiz/diagnostics.py @@ -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 diff --git a/tests/components/overkiz/test_diagnostics.py b/tests/components/overkiz/test_diagnostics.py index f6f7a7c3953..cf993be06ea 100644 --- a/tests/components/overkiz/test_diagnostics.py +++ b/tests/components/overkiz/test_diagnostics.py @@ -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"]), + ] + + 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)"]