Skip to content

Commit 102689b

Browse files
agnersbramkragten
authored andcommitted
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.
1 parent b16d769 commit 102689b

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import type { HomeAssistant } from "../../../../src/types";
2121
import type { HassioDatatiskDialogParams } from "./show-dialog-hassio-datadisk";
2222

2323
const calculateMoveTime = memoizeOne((supervisor: Supervisor): number => {
24-
const speed = supervisor.host.disk_life_time !== "" ? 30 : 10;
25-
const moveTime = (supervisor.host.disk_used * 1000) / 60 / speed;
24+
// Assume a speed of 30 MB/s.
25+
const moveTime = (supervisor.host.disk_used * 1000) / 60 / 30;
2626
const rebootTime = (supervisor.host.startup_time * 4) / 60;
2727
return Math.ceil((moveTime + rebootTime) / 10) * 10;
2828
});

hassio/src/system/hassio-host-info.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,12 @@ class HassioHostInfo extends LitElement {
143143
: ""}
144144
</div>
145145
<div>
146-
${this.supervisor.host.disk_life_time !== "" &&
147-
this.supervisor.host.disk_life_time >= 10
146+
${this.supervisor.host.disk_life_time !== null
148147
? html` <ha-settings-row>
149148
<span slot="heading">
150-
${this.supervisor.localize(
151-
"system.host.emmc_lifetime_used"
152-
)}
149+
${this.supervisor.localize("system.host.lifetime_used")}
153150
</span>
154151
<span slot="description">
155-
${this.supervisor.host.disk_life_time - 10} % -
156152
${this.supervisor.host.disk_life_time} %
157153
</span>
158154
</ha-settings-row>`

src/data/hassio/host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface HassioHostInfo {
88
chassis: string;
99
cpe: string;
1010
deployment: string;
11-
disk_life_time: number | "";
11+
disk_life_time: number | null;
1212
disk_free: number;
1313
disk_total: number;
1414
disk_used: number;

src/panels/config/storage/dialog-move-datadisk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import { bytesToString } from "../../../util/bytes-to-string";
3030
import type { MoveDatadiskDialogParams } from "./show-dialog-move-datadisk";
3131

3232
const calculateMoveTime = memoizeOne((hostInfo: HassioHostInfo): number => {
33-
const speed = hostInfo.disk_life_time !== "" ? 30 : 10;
34-
const moveTime = (hostInfo.disk_used * 1000) / 60 / speed;
33+
// Assume a speed of 30 MB/s.
34+
const moveTime = (hostInfo.disk_used * 1000) / 60 / 30;
3535
const rebootTime = (hostInfo.startup_time * 4) / 60;
3636
return Math.ceil((moveTime + rebootTime) / 10) * 10;
3737
});

src/panels/config/storage/ha-config-section-storage.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,17 @@ class HaConfigSectionStorage extends LitElement {
117117
}
118118
)}
119119
</div>
120-
${this._hostInfo.disk_life_time !== "" &&
121-
this._hostInfo.disk_life_time >= 10
120+
${this._hostInfo.disk_life_time !== null
122121
? // prettier-ignore
123122
html`
124123
<ha-metric
125124
.heading=${this.hass.localize(
126-
"ui.panel.config.storage.emmc_lifetime_used"
125+
"ui.panel.config.storage.lifetime_used"
127126
)}
128127
.value=${this._hostInfo.disk_life_time}
129-
.tooltip=${`${this._hostInfo.disk_life_time - 10}% - ${this._hostInfo.disk_life_time}%`}
128+
.tooltip=${this.hass.localize(
129+
"ui.panel.config.storage.lifetime_used_description"
130+
)}
130131
class="emmc"
131132
></ha-metric>
132133
`

src/translations/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6614,7 +6614,8 @@
66146614
"description": "{percent_used} used - {free_space} free",
66156615
"used_space": "Used space",
66166616
"detailed_description": "{used} used of {total} total, {free_space} remaining",
6617-
"emmc_lifetime_used": "eMMC lifetime used",
6617+
"lifetime_used": "Lifetime used",
6618+
"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.",
66186619
"disk_metrics": "Disk metrics",
66196620
"datadisk": {
66206621
"title": "Move data disk",
@@ -9428,7 +9429,7 @@
94289429
"operating_system": "Operating system",
94299430
"docker_version": "Docker version",
94309431
"deployment": "Deployment",
9431-
"emmc_lifetime_used": "eMMC lifetime used",
9432+
"lifetime_used": "Lifetime used",
94329433
"reboot_host": "Reboot host",
94339434
"confirm_reboot": "Are you sure you want to reboot the host?",
94349435
"confirm_shutdown": "Are you sure you want to shut down the host?",

0 commit comments

Comments
 (0)