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 7d6200bd58..f8245a891f 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 @@ -116,10 +116,11 @@ class HaBackupConfigAgents extends LitElement { this.value = this._value.filter((agent) => agent !== agentId); } - // Ensure agents exist in the list - this.value = this.value + // 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); + .filter((id) => id !== CLOUD_AGENT || this.cloudStatus.logged_in); + fireEvent(this, "value-changed", { value: this.value }); } diff --git a/src/panels/config/backup/dialogs/dialog-backup-onboarding.ts b/src/panels/config/backup/dialogs/dialog-backup-onboarding.ts index e373a3ad36..3a17c454f9 100644 --- a/src/panels/config/backup/dialogs/dialog-backup-onboarding.ts +++ b/src/panels/config/backup/dialogs/dialog-backup-onboarding.ts @@ -96,18 +96,26 @@ class DialogBackupOnboarding extends LitElement implements HassDialog { this._step = this._steps[0]; this._config = RECOMMENDED_CONFIG; + const agents: string[] = []; // Enable local location by default if (isComponentLoaded(this.hass, "hassio")) { - this._config.create_backup.agent_ids.push(HASSIO_LOCAL_AGENT); + agents.push(HASSIO_LOCAL_AGENT); } else { - this._config.create_backup.agent_ids.push(CORE_LOCAL_AGENT); + agents.push(CORE_LOCAL_AGENT); } // Enable cloud location if logged in if (this._params.cloudStatus.logged_in) { - this._config.create_backup.agent_ids.push(CLOUD_AGENT); + agents.push(CLOUD_AGENT); } - this._config.create_backup.password = generateEncryptionKey(); + this._config = { + ...this._config, + create_backup: { + ...this._config.create_backup, + agent_ids: agents, + password: generateEncryptionKey(), + }, + }; this._opened = true; }