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.
This commit is contained in:
Stefan Agner 2025-08-05 10:42:42 +02:00 committed by GitHub
parent 6068c32176
commit 92cf8b5579
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 17 deletions

View File

@ -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;
});

View File

@ -143,16 +143,12 @@ class HassioHostInfo extends LitElement {
: ""}
</div>
<div>
${this.supervisor.host.disk_life_time !== "" &&
this.supervisor.host.disk_life_time >= 10
${this.supervisor.host.disk_life_time !== null
? html` <ha-settings-row>
<span slot="heading">
${this.supervisor.localize(
"system.host.emmc_lifetime_used"
)}
${this.supervisor.localize("system.host.lifetime_used")}
</span>
<span slot="description">
${this.supervisor.host.disk_life_time - 10} % -
${this.supervisor.host.disk_life_time} %
</span>
</ha-settings-row>`

View File

@ -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;

View File

@ -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;
});

View File

@ -117,16 +117,17 @@ class HaConfigSectionStorage extends LitElement {
}
)}
</div>
${this._hostInfo.disk_life_time !== "" &&
this._hostInfo.disk_life_time >= 10
${this._hostInfo.disk_life_time !== null
? // prettier-ignore
html`
<ha-metric
.heading=${this.hass.localize(
"ui.panel.config.storage.emmc_lifetime_used"
"ui.panel.config.storage.lifetime_used"
)}
.value=${this._hostInfo.disk_life_time}
.tooltip=${`${this._hostInfo.disk_life_time - 10}% - ${this._hostInfo.disk_life_time}%`}
.tooltip=${this.hass.localize(
"ui.panel.config.storage.lifetime_used_description"
)}
class="emmc"
></ha-metric>
`

View File

@ -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 drives 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?",