mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Allow Google unlocking locks (#2073)
* Allow Google unlocking locks * Fix missing type
This commit is contained in:
parent
c01bd57ba5
commit
2ca3a784e2
@ -24,7 +24,7 @@ export class CloudAlexaPref extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const enabled = this.cloudStatus!.alexa_enabled;
|
const enabled = this.cloudStatus!.prefs.alexa_enabled;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
|
@ -25,13 +25,14 @@ export class CloudGooglePref extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const enabled = this.cloudStatus!.google_enabled;
|
const { google_enabled, google_allow_unlock } = this.cloudStatus!.prefs;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this.renderStyle()}
|
${this.renderStyle()}
|
||||||
<paper-card heading="Google Assistant">
|
<paper-card heading="Google Assistant">
|
||||||
<paper-toggle-button
|
<paper-toggle-button
|
||||||
.checked="${enabled}"
|
id="google_enabled"
|
||||||
|
.checked="${google_enabled}"
|
||||||
@change="${this._toggleChanged}"
|
@change="${this._toggleChanged}"
|
||||||
></paper-toggle-button>
|
></paper-toggle-button>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -61,8 +62,16 @@ export class CloudGooglePref extends LitElement {
|
|||||||
the Google Home or Android phone.</em
|
the Google Home or Android phone.</em
|
||||||
>
|
>
|
||||||
${
|
${
|
||||||
enabled
|
google_enabled
|
||||||
? html`
|
? 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>
|
<p>Exposed entities:</p>
|
||||||
<cloud-exposed-entities
|
<cloud-exposed-entities
|
||||||
.hass="${this.hass}"
|
.hass="${this.hass}"
|
||||||
@ -76,7 +85,7 @@ export class CloudGooglePref extends LitElement {
|
|||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-call-api-button
|
<ha-call-api-button
|
||||||
.hass="${this.hass}"
|
.hass="${this.hass}"
|
||||||
.disabled="${!enabled}"
|
.disabled="${!google_enabled}"
|
||||||
path="cloud/google_actions/sync"
|
path="cloud/google_actions/sync"
|
||||||
>Sync devices</ha-call-api-button
|
>Sync devices</ha-call-api-button
|
||||||
>
|
>
|
||||||
@ -88,7 +97,7 @@ export class CloudGooglePref extends LitElement {
|
|||||||
private async _toggleChanged(ev) {
|
private async _toggleChanged(ev) {
|
||||||
const toggle = ev.target as PaperToggleButtonElement;
|
const toggle = ev.target as PaperToggleButtonElement;
|
||||||
try {
|
try {
|
||||||
await updatePref(this.hass!, { google_enabled: toggle.checked! });
|
await updatePref(this.hass!, { [toggle.id]: toggle.checked! });
|
||||||
fireEvent(this, "ha-refresh-cloud-status");
|
fireEvent(this, "ha-refresh-cloud-status");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toggle.checked = !toggle.checked;
|
toggle.checked = !toggle.checked;
|
||||||
@ -110,6 +119,14 @@ export class CloudGooglePref extends LitElement {
|
|||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
.unlock {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
.unlock > div {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export const updatePref = (
|
|||||||
prefs: {
|
prefs: {
|
||||||
google_enabled?: boolean;
|
google_enabled?: boolean;
|
||||||
alexa_enabled?: boolean;
|
alexa_enabled?: boolean;
|
||||||
|
google_allow_unlock?: boolean;
|
||||||
}
|
}
|
||||||
) =>
|
) =>
|
||||||
hass.callWS({
|
hass.callWS({
|
||||||
|
@ -11,12 +11,15 @@ interface CloudStatusBase {
|
|||||||
|
|
||||||
export type CloudStatusLoggedIn = CloudStatusBase & {
|
export type CloudStatusLoggedIn = CloudStatusBase & {
|
||||||
email: string;
|
email: string;
|
||||||
google_enabled: boolean;
|
|
||||||
google_entities: EntityFilter;
|
google_entities: EntityFilter;
|
||||||
google_domains: string[];
|
google_domains: string[];
|
||||||
alexa_enabled: boolean;
|
|
||||||
alexa_entities: EntityFilter;
|
alexa_entities: EntityFilter;
|
||||||
alexa_domains: string[];
|
alexa_domains: string[];
|
||||||
|
prefs: {
|
||||||
|
google_enabled: boolean;
|
||||||
|
alexa_enabled: boolean;
|
||||||
|
google_allow_unlock: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CloudStatus = CloudStatusBase | CloudStatusLoggedIn;
|
export type CloudStatus = CloudStatusBase | CloudStatusLoggedIn;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user