mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Add Alexa report state (#3272)
This commit is contained in:
parent
a9cac343b0
commit
1add5077af
@ -35,6 +35,7 @@ export interface CloudPreferences {
|
|||||||
alexa_entity_configs: {
|
alexa_entity_configs: {
|
||||||
[entityId: string]: AlexaEntityConfig;
|
[entityId: string]: AlexaEntityConfig;
|
||||||
};
|
};
|
||||||
|
alexa_report_state: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CloudStatusLoggedIn = CloudStatusBase & {
|
export type CloudStatusLoggedIn = CloudStatusBase & {
|
||||||
@ -42,7 +43,6 @@ export type CloudStatusLoggedIn = CloudStatusBase & {
|
|||||||
google_entities: EntityFilter;
|
google_entities: EntityFilter;
|
||||||
google_domains: string[];
|
google_domains: string[];
|
||||||
alexa_entities: EntityFilter;
|
alexa_entities: EntityFilter;
|
||||||
alexa_domains: string[];
|
|
||||||
prefs: CloudPreferences;
|
prefs: CloudPreferences;
|
||||||
remote_domain: string | undefined;
|
remote_domain: string | undefined;
|
||||||
remote_connected: boolean;
|
remote_connected: boolean;
|
||||||
@ -95,6 +95,7 @@ export const updateCloudPref = (
|
|||||||
prefs: {
|
prefs: {
|
||||||
google_enabled?: CloudPreferences["google_enabled"];
|
google_enabled?: CloudPreferences["google_enabled"];
|
||||||
alexa_enabled?: CloudPreferences["alexa_enabled"];
|
alexa_enabled?: CloudPreferences["alexa_enabled"];
|
||||||
|
alexa_report_state?: CloudPreferences["alexa_report_state"];
|
||||||
google_secure_devices_pin?: CloudPreferences["google_secure_devices_pin"];
|
google_secure_devices_pin?: CloudPreferences["google_secure_devices_pin"];
|
||||||
}
|
}
|
||||||
) =>
|
) =>
|
||||||
|
@ -33,13 +33,13 @@ export class CloudAlexaPref extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enabled = this.cloudStatus!.prefs.alexa_enabled;
|
const { alexa_enabled, alexa_report_state } = this.cloudStatus!.prefs;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Alexa">
|
<ha-card header="Alexa">
|
||||||
<paper-toggle-button
|
<paper-toggle-button
|
||||||
.checked="${enabled}"
|
.checked=${alexa_enabled}
|
||||||
@change="${this._toggleChanged}"
|
@change=${this._enabledToggleChanged}
|
||||||
></paper-toggle-button>
|
></paper-toggle-button>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
With the Alexa integration for Home Assistant Cloud you'll be able to
|
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
|
>This integration requires an Alexa-enabled device like the Amazon
|
||||||
Echo.</em
|
Echo.</em
|
||||||
>
|
>
|
||||||
|
${alexa_enabled
|
||||||
|
? html`
|
||||||
|
<h3>Enable State Reporting</h3>
|
||||||
|
<p>
|
||||||
|
If you enable state reporting, Home Assistant will sent
|
||||||
|
<b>all</b> 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.
|
||||||
|
</p>
|
||||||
|
<paper-toggle-button
|
||||||
|
.checked=${alexa_report_state}
|
||||||
|
@change=${this._reportToggleChanged}
|
||||||
|
></paper-toggle-button>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
@ -73,7 +88,7 @@ export class CloudAlexaPref extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _toggleChanged(ev) {
|
private async _enabledToggleChanged(ev) {
|
||||||
const toggle = ev.target as PaperToggleButtonElement;
|
const toggle = ev.target as PaperToggleButtonElement;
|
||||||
try {
|
try {
|
||||||
await updateCloudPref(this.hass!, { alexa_enabled: toggle.checked! });
|
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 {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
a {
|
a {
|
||||||
@ -103,6 +130,12 @@ export class CloudAlexaPref extends LitElement {
|
|||||||
.spacer {
|
.spacer {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
h3 {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
h3 + p {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user