diff --git a/homeassistant/components/repairs/websocket_api.py b/homeassistant/components/repairs/websocket_api.py index 2e4e166f3e9..b6a71773273 100644 --- a/homeassistant/components/repairs/websocket_api.py +++ b/homeassistant/components/repairs/websocket_api.py @@ -73,6 +73,7 @@ def ws_list_issues( issues = [ dataclasses.asdict(issue, dict_factory=ws_dict) for issue in issue_registry.issues.values() + if issue.active ] connection.send_result(msg["id"], {"issues": issues}) diff --git a/tests/components/repairs/test_websocket_api.py b/tests/components/repairs/test_websocket_api.py index 388912e0adc..73d1898fcb7 100644 --- a/tests/components/repairs/test_websocket_api.py +++ b/tests/components/repairs/test_websocket_api.py @@ -9,7 +9,11 @@ import pytest import voluptuous as vol from homeassistant import data_entry_flow -from homeassistant.components.repairs import RepairsFlow, async_create_issue +from homeassistant.components.repairs import ( + RepairsFlow, + async_create_issue, + issue_registry, +) from homeassistant.components.repairs.const import DOMAIN from homeassistant.const import __version__ as ha_version from homeassistant.core import HomeAssistant @@ -366,8 +370,24 @@ async def test_step_unauth( @freeze_time("2022-07-19 07:53:05") -async def test_list_issues(hass: HomeAssistant, hass_ws_client) -> None: +async def test_list_issues(hass: HomeAssistant, hass_storage, hass_ws_client) -> None: """Test we can list issues.""" + + # Add an inactive issue, this should not be exposed in the list + hass_storage[issue_registry.STORAGE_KEY] = { + "version": issue_registry.STORAGE_VERSION, + "data": { + "issues": [ + { + "created": "2022-07-19T09:41:13.746514+00:00", + "dismissed_version": None, + "domain": "test", + "issue_id": "issue_3_inactive", + }, + ] + }, + } + assert await async_setup_component(hass, DOMAIN, {}) client = await hass_ws_client(hass)