Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hassio/src/dialogs/datadisk/dialog-hassio-datadisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is using the disk_life_time estimate as indication of if this is an eMMC (and with that an estimated disk speed).

From what I can tell the Supervisor API always returned null if there was no eMMC disk life time used estimate available (see home-assistant/supervisor#2413).

Anyhow, since most folks use faster storage nowadays, 30MB/s seems like a reasonable general estimate today.

So essentially, this code defaulted to 30MB/s anyways.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean it is, and was, wrong for eMMC storage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what the speed intention was, I guess eMMC was considered faster then SD card. But since null (non-eMMC) and a number (eMMC) evaluated to true, the "SD card" (or rather non-eMMC) case was broken.

const rebootTime = (supervisor.host.startup_time * 4) / 60;
return Math.ceil((moveTime + rebootTime) / 10) * 10;
});
Expand Down
8 changes: 2 additions & 6 deletions hassio/src/system/hassio-host-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>`
Expand Down
2 changes: 1 addition & 1 deletion src/data/hassio/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/panels/config/storage/dialog-move-datadisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
9 changes: 5 additions & 4 deletions src/panels/config/storage/ha-config-section-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
`
Expand Down
5 changes: 3 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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?",
Expand Down
Loading