diff --git a/src/data/update.ts b/src/data/update.ts index e80fb2f285..f5d3af7dea 100644 --- a/src/data/update.ts +++ b/src/data/update.ts @@ -207,7 +207,11 @@ export const computeUpdateStateDisplay = ( return hass.formatEntityState(stateObj); }; -export type UpdateType = "addon" | "home_assistant" | "generic"; +export type UpdateType = + | "addon" + | "home_assistant" + | "home_assistant_os" + | "generic"; export const getUpdateType = ( stateObj: UpdateEntity, @@ -215,6 +219,7 @@ export const getUpdateType = ( ): UpdateType => { const entity_id = stateObj.entity_id; const domain = entitySources[entity_id]?.domain; + if (domain !== "hassio") { return "generic"; } @@ -224,13 +229,11 @@ export const getUpdateType = ( return "home_assistant"; } - if ( - ![ - HOME_ASSISTANT_CORE_TITLE, - HOME_ASSISTANT_SUPERVISOR_TITLE, - HOME_ASSISTANT_OS_TITLE, - ].includes(title) - ) { + if (title === HOME_ASSISTANT_OS_TITLE) { + return "home_assistant_os"; + } + + if (title !== HOME_ASSISTANT_SUPERVISOR_TITLE) { return "addon"; } return "generic"; diff --git a/src/dialogs/more-info/controls/more-info-update.ts b/src/dialogs/more-info/controls/more-info-update.ts index d4e0503604..82d224b0fa 100644 --- a/src/dialogs/more-info/controls/more-info-update.ts +++ b/src/dialogs/more-info/controls/more-info-update.ts @@ -64,7 +64,8 @@ class MoreInfoUpdate extends LitElement { try { const config = await getSupervisorUpdateConfig(this.hass); - if (type === "home_assistant") { + // for home assistant and OS updates + if (this._isHaOrOsUpdate(type)) { this._createBackup = config.core_backup_before_update; return; } @@ -83,6 +84,10 @@ class MoreInfoUpdate extends LitElement { this._entitySources = await fetchEntitySourcesWithCache(this.hass); } + private _isHaOrOsUpdate(type: UpdateType): boolean { + return ["home_assistant", "home_assistant_os"].includes(type); + } + private _computeCreateBackupTexts(): | { title: string; description?: string } | undefined { @@ -97,8 +102,7 @@ class MoreInfoUpdate extends LitElement { ? getUpdateType(this.stateObj, this._entitySources) : "generic"; - // Automatic or manual for Home Assistant update - if (updateType === "home_assistant") { + if (this._isHaOrOsUpdate(updateType)) { const isBackupConfigValid = !!this._backupConfig && !!this._backupConfig.automatic_backups_configured && @@ -350,11 +354,12 @@ class MoreInfoUpdate extends LitElement { const type = getUpdateType(this.stateObj!, this._entitySources!); if ( isComponentLoaded(this.hass, "hassio") && - ["home_assistant", "addon"].includes(type) + ["addon", "home_assistant", "home_assistant_os"].includes(type) ) { this._fetchUpdateBackupConfig(type); } - if (type === "home_assistant") { + + if (this._isHaOrOsUpdate(type)) { this._fetchBackupConfig(); } });