Compare commits

...

1 Commits

Author SHA1 Message Date
Bram Kragten
a27b524544 Revert "Add support for update entity's update_percentage state attribute (#2…"
This reverts commit f1ab24da99.
2024-10-23 13:37:57 +02:00
3 changed files with 10 additions and 11 deletions

View File

@@ -24,13 +24,12 @@ export enum UpdateEntityFeature {
interface UpdateEntityAttributes extends HassEntityAttributeBase {
auto_update: boolean | null;
installed_version: string | null;
in_progress: boolean;
in_progress: boolean | number;
latest_version: string | null;
release_summary: string | null;
release_url: string | null;
skipped_version: string | null;
title: string | null;
update_percentage: number | null;
}
export interface UpdateEntity extends HassEntityBase {
@@ -39,7 +38,7 @@ export interface UpdateEntity extends HassEntityBase {
export const updateUsesProgress = (entity: UpdateEntity): boolean =>
supportsFeature(entity, UpdateEntityFeature.PROGRESS) &&
entity.attributes.update_percentage !== null;
typeof entity.attributes.in_progress === "number";
export const updateCanInstall = (
entity: UpdateEntity,
@@ -50,7 +49,7 @@ export const updateCanInstall = (
supportsFeature(entity, UpdateEntityFeature.INSTALL);
export const updateIsInstalling = (entity: UpdateEntity): boolean =>
!!entity.attributes.in_progress;
updateUsesProgress(entity) || !!entity.attributes.in_progress;
export const updateReleaseNotes = (hass: HomeAssistant, entityId: string) =>
hass.callWS<string | null>({
@@ -184,10 +183,10 @@ export const computeUpdateStateDisplay = (
if (updateIsInstalling(stateObj)) {
const supportsProgress =
supportsFeature(stateObj, UpdateEntityFeature.PROGRESS) &&
attributes.update_percentage !== null;
typeof attributes.in_progress === "number";
if (supportsProgress) {
return hass.localize("ui.card.update.installing_with_progress", {
progress: attributes.update_percentage,
progress: attributes.in_progress as number,
});
}
return hass.localize("ui.card.update.installing");

View File

@@ -47,9 +47,9 @@ class MoreInfoUpdate extends LitElement {
return html`
${this.stateObj.attributes.in_progress
? supportsFeature(this.stateObj, UpdateEntityFeature.PROGRESS) &&
this.stateObj.attributes.update_percentage !== null
typeof this.stateObj.attributes.in_progress === "number"
? html`<mwc-linear-progress
.progress=${this.stateObj.attributes.update_percentage / 100}
.progress=${this.stateObj.attributes.in_progress / 100}
buffer=""
></mwc-linear-progress>`
: html`<mwc-linear-progress indeterminate></mwc-linear-progress>`

View File

@@ -54,7 +54,7 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
const stateObj = this.hass.states[this.updateEntityId];
const progressIsNumeric =
typeof stateObj?.attributes.update_percentage !== null;
typeof stateObj?.attributes.in_progress === "number";
return html`<div class="content">
<img src="/static/icons/casita/loading.png" />
@@ -69,7 +69,7 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
</p>
<ha-circular-progress
.value=${progressIsNumeric
? stateObj.attributes.update_percentage / 100
? stateObj.attributes.in_progress / 100
: undefined}
.indeterminate=${!progressIsNumeric}
></ha-circular-progress>
@@ -77,7 +77,7 @@ export class HaVoiceAssistantSetupStepUpdate extends LitElement {
${stateObj.state === "unavailable"
? "Restarting voice assistant"
: progressIsNumeric
? `Installing ${stateObj.attributes.update_percentage}%`
? `Installing ${stateObj.attributes.in_progress}%`
: ""}
</p>
</div>`;