From 0891e7a0a7d4221adf690fb088ece7c13d8ea30a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 31 Dec 2024 14:50:37 +0100 Subject: [PATCH] Handle no cloud subscription better in backups --- .../config/ha-backup-config-agents.ts | 17 +++++++++++++++-- .../backup/dialogs/dialog-generate-backup.ts | 5 ++++- .../backup/dialogs/dialog-upload-backup.ts | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/panels/config/backup/components/config/ha-backup-config-agents.ts b/src/panels/config/backup/components/config/ha-backup-config-agents.ts index de74488dcff9..3a1706f3d453 100644 --- a/src/panels/config/backup/components/config/ha-backup-config-agents.ts +++ b/src/panels/config/backup/components/config/ha-backup-config-agents.ts @@ -51,6 +51,9 @@ class HaBackupConfigAgents extends LitElement { private _description(agentId: string) { if (agentId === CLOUD_AGENT) { + if (this.cloudStatus.logged_in && !this.cloudStatus.active_subscription) { + return "You currently do not have an active Home Assistant Cloud subscription."; + } return "Note: It stores only one backup with a maximum size of 5 GB, regardless of your settings."; } if (isNetworkMountAgent(agentId)) { @@ -72,6 +75,10 @@ class HaBackupConfigAgents extends LitElement { this._agentIds ); const description = this._description(agentId); + const noCloudSubscription = + agentId === CLOUD_AGENT && + this.cloudStatus.logged_in && + !this.cloudStatus.active_subscription; return html` ${isLocalAgent(agentId) @@ -107,7 +114,9 @@ class HaBackupConfigAgents extends LitElement { @@ -133,7 +142,11 @@ class HaBackupConfigAgents extends LitElement { // Ensure we don't have duplicates, agents exist in the list and cloud is logged in this.value = [...new Set(this.value)] .filter((agent) => this._agentIds.some((id) => id === agent)) - .filter((id) => id !== CLOUD_AGENT || this.cloudStatus.logged_in); + .filter( + (id) => + id !== CLOUD_AGENT || + (this.cloudStatus.logged_in && this.cloudStatus.active_subscription) + ); fireEvent(this, "value-changed", { value: this.value }); } diff --git a/src/panels/config/backup/dialogs/dialog-generate-backup.ts b/src/panels/config/backup/dialogs/dialog-generate-backup.ts index 866aaf441ddc..e6185d485883 100644 --- a/src/panels/config/backup/dialogs/dialog-generate-backup.ts +++ b/src/panels/config/backup/dialogs/dialog-generate-backup.ts @@ -100,7 +100,10 @@ class DialogGenerateBackup extends LitElement implements HassDialog { this._agentIds = agents .map((agent) => agent.agent_id) .filter( - (id) => id !== CLOUD_AGENT || this._params?.cloudStatus?.logged_in + (id) => + id !== CLOUD_AGENT || + (this._params?.cloudStatus?.logged_in && + this._params?.cloudStatus?.active_subscription) ) .sort(compareAgents); } diff --git a/src/panels/config/backup/dialogs/dialog-upload-backup.ts b/src/panels/config/backup/dialogs/dialog-upload-backup.ts index a9b3e9262ce9..ff3e454f2238 100644 --- a/src/panels/config/backup/dialogs/dialog-upload-backup.ts +++ b/src/panels/config/backup/dialogs/dialog-upload-backup.ts @@ -20,7 +20,6 @@ import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; import { haStyle, haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; import { showAlertDialog } from "../../../lovelace/custom-card-helpers"; -import "../components/ha-backup-agents-picker"; import type { UploadBackupDialogParams } from "./show-dialog-upload-backup"; const SUPPORTED_FORMAT = "application/x-tar";