From 20ce7e0dcfb3ac4102d3f4fb2392f035e7314931 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 4 Aug 2025 13:49:01 +0200 Subject: [PATCH 1/2] Remove eMMC specific references in disk life time handling Remove eMMC specific calculations and references in the disk life time handling to generalize the code for all disk types. This includes updating translations and UI components to reflect a more generic approach to disk life time metrics. --- hassio/src/system/hassio-host-info.ts | 8 ++------ src/data/hassio/host.ts | 2 +- src/panels/config/storage/ha-config-section-storage.ts | 9 +++++---- src/translations/en.json | 5 +++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hassio/src/system/hassio-host-info.ts b/hassio/src/system/hassio-host-info.ts index 6c9657a55d1e..69c935701fa6 100644 --- a/hassio/src/system/hassio-host-info.ts +++ b/hassio/src/system/hassio-host-info.ts @@ -143,16 +143,12 @@ class HassioHostInfo extends LitElement { : ""}
- ${this.supervisor.host.disk_life_time !== "" && - this.supervisor.host.disk_life_time >= 10 + ${this.supervisor.host.disk_life_time !== null ? html` - ${this.supervisor.localize( - "system.host.emmc_lifetime_used" - )} + ${this.supervisor.localize("system.host.lifetime_used")} - ${this.supervisor.host.disk_life_time - 10} % - ${this.supervisor.host.disk_life_time} % ` diff --git a/src/data/hassio/host.ts b/src/data/hassio/host.ts index 46452aa212cd..432a5afe2142 100644 --- a/src/data/hassio/host.ts +++ b/src/data/hassio/host.ts @@ -8,7 +8,7 @@ export interface HassioHostInfo { chassis: string; cpe: string; deployment: string; - disk_life_time: number | ""; + disk_life_time: number | null; disk_free: number; disk_total: number; disk_used: number; diff --git a/src/panels/config/storage/ha-config-section-storage.ts b/src/panels/config/storage/ha-config-section-storage.ts index 598d13214f4c..94f594ebe221 100644 --- a/src/panels/config/storage/ha-config-section-storage.ts +++ b/src/panels/config/storage/ha-config-section-storage.ts @@ -117,16 +117,17 @@ class HaConfigSectionStorage extends LitElement { } )}
- ${this._hostInfo.disk_life_time !== "" && - this._hostInfo.disk_life_time >= 10 + ${this._hostInfo.disk_life_time !== null ? // prettier-ignore html` ` diff --git a/src/translations/en.json b/src/translations/en.json index 3e10edd42f92..af9592bd2f72 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -6614,7 +6614,8 @@ "description": "{percent_used} used - {free_space} free", "used_space": "Used space", "detailed_description": "{used} used of {total} total, {free_space} remaining", - "emmc_lifetime_used": "eMMC lifetime used", + "lifetime_used": "Lifetime used", + "lifetime_used_description": "The drive’s wear level is shown as a percentage, based on endurance indicators reported by the device via NVMe SMART or eMMC lifetime estimate fields.", "disk_metrics": "Disk metrics", "datadisk": { "title": "Move data disk", @@ -9428,7 +9429,7 @@ "operating_system": "Operating system", "docker_version": "Docker version", "deployment": "Deployment", - "emmc_lifetime_used": "eMMC lifetime used", + "lifetime_used": "Lifetime used", "reboot_host": "Reboot host", "confirm_reboot": "Are you sure you want to reboot the host?", "confirm_shutdown": "Are you sure you want to shut down the host?", From 1d1006f42bf803599e4baf4adadb55cd5a8fed11 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 4 Aug 2025 14:04:45 +0200 Subject: [PATCH 2/2] Assume 30 MB/s as the speed for disk operations The previous code tried to estimate based on disk type, 30 MB/s for eMMC devices and 10 MB/s for others. However, this did not work correctly since the disk_life_time returns null for non-eMMC devices, leading to 30 MB/s being used for all devices. Now disk_life_time is not a eMMC indicator anymore. Simply assume a constant speed of 30 MB/s for all disk operations explicitly. --- hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts | 4 ++-- src/panels/config/storage/dialog-move-datadisk.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts b/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts index 776d432d6873..9cd6c4d0878e 100644 --- a/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts +++ b/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts @@ -21,8 +21,8 @@ import type { HomeAssistant } from "../../../../src/types"; import type { HassioDatatiskDialogParams } from "./show-dialog-hassio-datadisk"; const calculateMoveTime = memoizeOne((supervisor: Supervisor): number => { - const speed = supervisor.host.disk_life_time !== "" ? 30 : 10; - const moveTime = (supervisor.host.disk_used * 1000) / 60 / speed; + // Assume a speed of 30 MB/s. + const moveTime = (supervisor.host.disk_used * 1000) / 60 / 30; const rebootTime = (supervisor.host.startup_time * 4) / 60; return Math.ceil((moveTime + rebootTime) / 10) * 10; }); diff --git a/src/panels/config/storage/dialog-move-datadisk.ts b/src/panels/config/storage/dialog-move-datadisk.ts index 2d89b2d0249d..4567c05a5ec3 100644 --- a/src/panels/config/storage/dialog-move-datadisk.ts +++ b/src/panels/config/storage/dialog-move-datadisk.ts @@ -30,8 +30,8 @@ import { bytesToString } from "../../../util/bytes-to-string"; import type { MoveDatadiskDialogParams } from "./show-dialog-move-datadisk"; const calculateMoveTime = memoizeOne((hostInfo: HassioHostInfo): number => { - const speed = hostInfo.disk_life_time !== "" ? 30 : 10; - const moveTime = (hostInfo.disk_used * 1000) / 60 / speed; + // Assume a speed of 30 MB/s. + const moveTime = (hostInfo.disk_used * 1000) / 60 / 30; const rebootTime = (hostInfo.startup_time * 4) / 60; return Math.ceil((moveTime + rebootTime) / 10) * 10; });