Skip to content

Commit 68c6641

Browse files
committed
Make disk_lifetime issue into a repair
1 parent 1a9d1a9 commit 68c6641

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

homeassistant/components/hassio/issues.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
ISSUE_KEY_SYSTEM_DOCKER_CONFIG,
104104
ISSUE_KEY_ADDON_DETACHED_ADDON_MISSING,
105105
ISSUE_KEY_ADDON_DETACHED_ADDON_REMOVED,
106+
"issue_system_disk_lifetime",
106107
}
107108

108109
_LOGGER = logging.getLogger(__name__)

homeassistant/components/hassio/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
}
116116
}
117117
},
118+
"issue_system_disk_lifetime": {
119+
"title": "Disk lifetime exceeding 90%",
120+
"description": "The disk reports it has exceeded 90% of its manufacturer expected lifetime. This means that the disk is nearing the end of its useful life and may begin to cause issues with the system. You should consider replacing it soon and then migrating to the new data disk."
121+
},
118122
"unhealthy": {
119123
"title": "Unhealthy system - {reason}",
120124
"description": "System is currently unhealthy due to {reason}. For troubleshooting information, select Learn more."

tests/components/hassio/test_issues.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,3 +850,50 @@ async def test_supervisor_issues_detached_addon_missing(
850850
"addon_url": "/hassio/addon/test",
851851
},
852852
)
853+
854+
855+
@pytest.mark.usefixtures("all_setup_requests")
856+
async def test_supervisor_issues_disk_lifetime(
857+
hass: HomeAssistant,
858+
supervisor_client: AsyncMock,
859+
hass_ws_client: WebSocketGenerator,
860+
) -> None:
861+
"""Test supervisor issue for disk lifetime nearly exceeded."""
862+
mock_resolution_info(supervisor_client)
863+
864+
result = await async_setup_component(hass, "hassio", {})
865+
assert result
866+
867+
client = await hass_ws_client(hass)
868+
869+
await client.send_json(
870+
{
871+
"id": 1,
872+
"type": "supervisor/event",
873+
"data": {
874+
"event": "issue_changed",
875+
"data": {
876+
"uuid": (issue_uuid := uuid4().hex),
877+
"type": "disk_lifetime",
878+
"context": "system",
879+
"reference": None,
880+
},
881+
},
882+
}
883+
)
884+
msg = await client.receive_json()
885+
assert msg["success"]
886+
await hass.async_block_till_done()
887+
888+
await client.send_json({"id": 2, "type": "repairs/list_issues"})
889+
msg = await client.receive_json()
890+
assert msg["success"]
891+
assert len(msg["result"]["issues"]) == 1
892+
assert_issue_repair_in_list(
893+
msg["result"]["issues"],
894+
uuid=issue_uuid,
895+
context="system",
896+
type_="disk_lifetime",
897+
fixable=False,
898+
placeholders=None,
899+
)

0 commit comments

Comments
 (0)