mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
Add support for external assist (#16556)
* Add support for external assist * Update hui-root.ts
This commit is contained in:
parent
e35d795ba8
commit
099aa54b80
@ -1,8 +1,18 @@
|
|||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
const loadVoiceCommandDialog = () => import("./ha-voice-command-dialog");
|
const loadVoiceCommandDialog = () => import("./ha-voice-command-dialog");
|
||||||
|
|
||||||
export const showVoiceCommandDialog = (element: HTMLElement): void => {
|
export const showVoiceCommandDialog = (
|
||||||
|
element: HTMLElement,
|
||||||
|
hass: HomeAssistant
|
||||||
|
): void => {
|
||||||
|
if (hass.auth.external?.config.hasAssist) {
|
||||||
|
hass.auth.external!.fireMessage({
|
||||||
|
type: "assist/show",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
fireEvent(element, "show-dialog", {
|
fireEvent(element, "show-dialog", {
|
||||||
dialogTag: "ha-voice-command-dialog",
|
dialogTag: "ha-voice-command-dialog",
|
||||||
dialogImport: loadVoiceCommandDialog,
|
dialogImport: loadVoiceCommandDialog,
|
||||||
|
@ -95,12 +95,21 @@ interface EMOutgoingMessageSidebarShow extends EMMessage {
|
|||||||
type: "sidebar/show";
|
type: "sidebar/show";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EMOutgoingMessageAssistShow extends EMMessage {
|
||||||
|
type: "assist/show";
|
||||||
|
payload?: {
|
||||||
|
pipeline_id?: string;
|
||||||
|
start_listening?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type EMOutgoingMessageWithoutAnswer =
|
type EMOutgoingMessageWithoutAnswer =
|
||||||
| EMOutgoingMessageHaptic
|
| EMOutgoingMessageHaptic
|
||||||
| EMOutgoingMessageConnectionStatus
|
| EMOutgoingMessageConnectionStatus
|
||||||
| EMOutgoingMessageAppConfiguration
|
| EMOutgoingMessageAppConfiguration
|
||||||
| EMOutgoingMessageTagWrite
|
| EMOutgoingMessageTagWrite
|
||||||
| EMOutgoingMessageSidebarShow
|
| EMOutgoingMessageSidebarShow
|
||||||
|
| EMOutgoingMessageAssistShow
|
||||||
| EMOutgoingMessageExoplayerPlayHLS
|
| EMOutgoingMessageExoplayerPlayHLS
|
||||||
| EMOutgoingMessageExoplayerResize
|
| EMOutgoingMessageExoplayerResize
|
||||||
| EMOutgoingMessageExoplayerStop
|
| EMOutgoingMessageExoplayerStop
|
||||||
@ -152,6 +161,7 @@ export interface ExternalConfig {
|
|||||||
canWriteTag: boolean;
|
canWriteTag: boolean;
|
||||||
hasExoPlayer: boolean;
|
hasExoPlayer: boolean;
|
||||||
canCommissionMatter: boolean;
|
canCommissionMatter: boolean;
|
||||||
|
hasAssist: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExternalMessaging {
|
export class ExternalMessaging {
|
||||||
|
@ -567,7 +567,7 @@ class HUIRoot extends LitElement {
|
|||||||
if (searchParams.edit === "1") {
|
if (searchParams.edit === "1") {
|
||||||
this.lovelace!.setEditMode(true);
|
this.lovelace!.setEditMode(true);
|
||||||
} else if (searchParams.conversation === "1") {
|
} else if (searchParams.conversation === "1") {
|
||||||
showVoiceCommandDialog(this);
|
showVoiceCommandDialog(this, this.hass);
|
||||||
window.history.replaceState(
|
window.history.replaceState(
|
||||||
null,
|
null,
|
||||||
"",
|
"",
|
||||||
@ -793,7 +793,7 @@ class HUIRoot extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _showVoiceCommandDialog(): void {
|
private _showVoiceCommandDialog(): void {
|
||||||
showVoiceCommandDialog(this);
|
showVoiceCommandDialog(this, this.hass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleEnableEditMode(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleEnableEditMode(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||||
|
@ -76,7 +76,7 @@ class PanelShoppingList extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _showVoiceCommandDialog(): void {
|
private _showVoiceCommandDialog(): void {
|
||||||
showVoiceCommandDialog(this);
|
showVoiceCommandDialog(this, this.hass);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user