mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Add report state toggle for Google (#3855)
This commit is contained in:
parent
b61bbee35a
commit
ef51f29e28
@ -36,6 +36,7 @@ export interface CloudPreferences {
|
||||
[entityId: string]: AlexaEntityConfig;
|
||||
};
|
||||
alexa_report_state: boolean;
|
||||
google_report_state: boolean;
|
||||
}
|
||||
|
||||
export type CloudStatusLoggedIn = CloudStatusBase & {
|
||||
@ -96,6 +97,7 @@ export const updateCloudPref = (
|
||||
google_enabled?: CloudPreferences["google_enabled"];
|
||||
alexa_enabled?: CloudPreferences["alexa_enabled"];
|
||||
alexa_report_state?: CloudPreferences["alexa_report_state"];
|
||||
google_report_state?: CloudPreferences["google_report_state"];
|
||||
google_secure_devices_pin?: CloudPreferences["google_secure_devices_pin"];
|
||||
}
|
||||
) =>
|
||||
|
@ -38,6 +38,7 @@ export class CloudGooglePref extends LitElement {
|
||||
|
||||
const {
|
||||
google_enabled,
|
||||
google_report_state,
|
||||
google_secure_devices_pin,
|
||||
} = this.cloudStatus.prefs;
|
||||
|
||||
@ -51,7 +52,7 @@ export class CloudGooglePref extends LitElement {
|
||||
<ha-switch
|
||||
id="google_enabled"
|
||||
.checked="${google_enabled}"
|
||||
@change="${this._toggleChanged}"
|
||||
@change="${this._enableToggleChanged}"
|
||||
></ha-switch>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
@ -85,6 +86,17 @@ export class CloudGooglePref extends LitElement {
|
||||
>
|
||||
${google_enabled
|
||||
? html`
|
||||
<h3>Enable State Reporting</h3>
|
||||
<p>
|
||||
If you enable state reporting, Home Assistant will send
|
||||
<b>all</b> state changes of exposed entities to Google. This
|
||||
allows you to always see the latest states in the Google app.
|
||||
</p>
|
||||
<ha-switch
|
||||
.checked=${google_report_state}
|
||||
@change=${this._reportToggleChanged}
|
||||
></ha-switch>
|
||||
|
||||
<div class="secure_devices">
|
||||
${this.hass!.localize(
|
||||
"ui.panel.config.cloud.account.google.enter_pin_info"
|
||||
@ -127,7 +139,7 @@ export class CloudGooglePref extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private async _toggleChanged(ev) {
|
||||
private async _enableToggleChanged(ev) {
|
||||
const toggle = ev.target as HaSwitch;
|
||||
try {
|
||||
await updateCloudPref(this.hass!, { [toggle.id]: toggle.checked! });
|
||||
@ -137,6 +149,23 @@ export class CloudGooglePref extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _reportToggleChanged(ev) {
|
||||
const toggle = ev.target as HaSwitch;
|
||||
try {
|
||||
await updateCloudPref(this.hass!, {
|
||||
google_report_state: toggle.checked!,
|
||||
});
|
||||
fireEvent(this, "ha-refresh-cloud-status");
|
||||
} catch (err) {
|
||||
alert(
|
||||
`Unable to ${toggle.checked ? "enable" : "disable"} report state. ${
|
||||
err.message
|
||||
}`
|
||||
);
|
||||
toggle.checked = !toggle.checked;
|
||||
}
|
||||
}
|
||||
|
||||
private async _pinChanged(ev) {
|
||||
const input = ev.target as PaperInputElement;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user