Skip to content

Commit

Permalink
Handle no cloud subscription better in backups
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten committed Dec 31, 2024
1 parent 455cd04 commit 0891e7a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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`
<ha-md-list-item>
${isLocalAgent(agentId)
Expand Down Expand Up @@ -107,7 +114,9 @@ class HaBackupConfigAgents extends LitElement {
<ha-switch
slot="end"
id=${agentId}
.checked=${this._value.includes(agentId)}
.checked=${!noCloudSubscription &&
this._value.includes(agentId)}
.disabled=${noCloudSubscription}
@change=${this._agentToggled}
></ha-switch>
</ha-md-list-item>
Expand All @@ -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 });
}
Expand Down
5 changes: 4 additions & 1 deletion src/panels/config/backup/dialogs/dialog-generate-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/panels/config/backup/dialogs/dialog-upload-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 0891e7a

Please sign in to comment.