diff --git a/src/data/cloud.ts b/src/data/cloud.ts index 3cb13c886b..0755aafcc7 100644 --- a/src/data/cloud.ts +++ b/src/data/cloud.ts @@ -35,6 +35,7 @@ export interface CloudPreferences { alexa_entity_configs: { [entityId: string]: AlexaEntityConfig; }; + alexa_report_state: boolean; } export type CloudStatusLoggedIn = CloudStatusBase & { @@ -42,7 +43,6 @@ export type CloudStatusLoggedIn = CloudStatusBase & { google_entities: EntityFilter; google_domains: string[]; alexa_entities: EntityFilter; - alexa_domains: string[]; prefs: CloudPreferences; remote_domain: string | undefined; remote_connected: boolean; @@ -95,6 +95,7 @@ export const updateCloudPref = ( prefs: { google_enabled?: CloudPreferences["google_enabled"]; alexa_enabled?: CloudPreferences["alexa_enabled"]; + alexa_report_state?: CloudPreferences["alexa_report_state"]; google_secure_devices_pin?: CloudPreferences["google_secure_devices_pin"]; } ) => diff --git a/src/panels/config/cloud/account/cloud-alexa-pref.ts b/src/panels/config/cloud/account/cloud-alexa-pref.ts index 669b1907c3..49ece9fd21 100644 --- a/src/panels/config/cloud/account/cloud-alexa-pref.ts +++ b/src/panels/config/cloud/account/cloud-alexa-pref.ts @@ -33,13 +33,13 @@ export class CloudAlexaPref extends LitElement { return html``; } - const enabled = this.cloudStatus!.prefs.alexa_enabled; + const { alexa_enabled, alexa_report_state } = this.cloudStatus!.prefs; return html`
With the Alexa integration for Home Assistant Cloud you'll be able to @@ -62,6 +62,21 @@ export class CloudAlexaPref extends LitElement { >This integration requires an Alexa-enabled device like the Amazon Echo. + ${alexa_enabled + ? html` +

Enable State Reporting

+

+ If you enable state reporting, Home Assistant will sent + all state changes of exposed entities to Amazon. This + allows you to always see the latest states in the Alexa app + and use the state changes to create routines. +

+ + ` + : ""}
@@ -73,7 +88,7 @@ export class CloudAlexaPref extends LitElement { `; } - private async _toggleChanged(ev) { + private async _enabledToggleChanged(ev) { const toggle = ev.target as PaperToggleButtonElement; try { await updateCloudPref(this.hass!, { alexa_enabled: toggle.checked! }); @@ -83,6 +98,18 @@ export class CloudAlexaPref extends LitElement { } } + private async _reportToggleChanged(ev) { + const toggle = ev.target as PaperToggleButtonElement; + try { + await updateCloudPref(this.hass!, { + alexa_report_state: toggle.checked!, + }); + fireEvent(this, "ha-refresh-cloud-status"); + } catch (err) { + toggle.checked = !toggle.checked; + } + } + static get styles(): CSSResult { return css` a { @@ -103,6 +130,12 @@ export class CloudAlexaPref extends LitElement { .spacer { flex-grow: 1; } + h3 { + margin-bottom: 0; + } + h3 + p { + margin-top: 0.5em; + } `; } }