From 92cf8b5579fea0ab23f09f9a9d1e0b72ee0f7157 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 5 Aug 2025 10:42:42 +0200 Subject: [PATCH] Remove eMMC specific references in disk life time handling (#26379) * 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. * 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 ++-- hassio/src/system/hassio-host-info.ts | 8 ++------ src/data/hassio/host.ts | 2 +- src/panels/config/storage/dialog-move-datadisk.ts | 4 ++-- src/panels/config/storage/ha-config-section-storage.ts | 9 +++++---- src/translations/en.json | 5 +++-- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts b/hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts index 776d432d68..9cd6c4d087 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/hassio/src/system/hassio-host-info.ts b/hassio/src/system/hassio-host-info.ts index 6c9657a55d..69c935701f 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 46452aa212..432a5afe21 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/dialog-move-datadisk.ts b/src/panels/config/storage/dialog-move-datadisk.ts index 2d89b2d024..4567c05a5e 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; }); diff --git a/src/panels/config/storage/ha-config-section-storage.ts b/src/panels/config/storage/ha-config-section-storage.ts index 598d13214f..94f594ebe2 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 3e10edd42f..af9592bd2f 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?",