Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/panels/config/cloud/cloud-alexa-pref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CloudAlexaPref extends LitElement {
}

protected render(): TemplateResult {
const enabled = this.cloudStatus!.alexa_enabled;
const enabled = this.cloudStatus!.prefs.alexa_enabled;

return html`
${this.renderStyle()}
Expand Down
27 changes: 22 additions & 5 deletions src/panels/config/cloud/cloud-google-pref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ export class CloudGooglePref extends LitElement {
}

protected render(): TemplateResult {
const enabled = this.cloudStatus!.google_enabled;
const { google_enabled, google_allow_unlock } = this.cloudStatus!.prefs;

return html`
${this.renderStyle()}
<paper-card heading="Google Assistant">
<paper-toggle-button
.checked="${enabled}"
id="google_enabled"
.checked="${google_enabled}"
@change="${this._toggleChanged}"
></paper-toggle-button>
<div class="card-content">
Expand Down Expand Up @@ -61,8 +62,16 @@ export class CloudGooglePref extends LitElement {
the Google Home or Android phone.</em
>
${
enabled
google_enabled
? html`
<div class="unlock">
<div>Allow unlocking locks</div>
<paper-toggle-button
id="google_allow_unlock"
.checked="${google_allow_unlock}"
@change="${this._toggleChanged}"
></paper-toggle-button>
</div>
<p>Exposed entities:</p>
<cloud-exposed-entities
.hass="${this.hass}"
Expand All @@ -76,7 +85,7 @@ export class CloudGooglePref extends LitElement {
<div class="card-actions">
<ha-call-api-button
.hass="${this.hass}"
.disabled="${!enabled}"
.disabled="${!google_enabled}"
path="cloud/google_actions/sync"
>Sync devices</ha-call-api-button
>
Expand All @@ -88,7 +97,7 @@ export class CloudGooglePref extends LitElement {
private async _toggleChanged(ev) {
const toggle = ev.target as PaperToggleButtonElement;
try {
await updatePref(this.hass!, { google_enabled: toggle.checked! });
await updatePref(this.hass!, { [toggle.id]: toggle.checked! });
fireEvent(this, "ha-refresh-cloud-status");
} catch (err) {
toggle.checked = !toggle.checked;
Expand All @@ -110,6 +119,14 @@ export class CloudGooglePref extends LitElement {
color: var(--primary-color);
font-weight: 500;
}
.unlock {
display: flex;
flex-direction: row;
padding-top: 16px;
}
.unlock > div {
flex: 1;
}
</style>
`;
}
Expand Down
1 change: 1 addition & 0 deletions src/panels/config/cloud/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const updatePref = (
prefs: {
google_enabled?: boolean;
alexa_enabled?: boolean;
google_allow_unlock?: boolean;
}
) =>
hass.callWS({
Expand Down
7 changes: 5 additions & 2 deletions src/panels/config/cloud/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ interface CloudStatusBase {

export type CloudStatusLoggedIn = CloudStatusBase & {
email: string;
google_enabled: boolean;
google_entities: EntityFilter;
google_domains: string[];
alexa_enabled: boolean;
alexa_entities: EntityFilter;
alexa_domains: string[];
prefs: {
google_enabled: boolean;
alexa_enabled: boolean;
google_allow_unlock: boolean;
};
};

export type CloudStatus = CloudStatusBase | CloudStatusLoggedIn;
Expand Down