mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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 { HomeAssistant } from "../../types";
|
||||
|
||||
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", {
|
||||
dialogTag: "ha-voice-command-dialog",
|
||||
dialogImport: loadVoiceCommandDialog,
|
||||
|
@ -95,12 +95,21 @@ interface EMOutgoingMessageSidebarShow extends EMMessage {
|
||||
type: "sidebar/show";
|
||||
}
|
||||
|
||||
interface EMOutgoingMessageAssistShow extends EMMessage {
|
||||
type: "assist/show";
|
||||
payload?: {
|
||||
pipeline_id?: string;
|
||||
start_listening?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
type EMOutgoingMessageWithoutAnswer =
|
||||
| EMOutgoingMessageHaptic
|
||||
| EMOutgoingMessageConnectionStatus
|
||||
| EMOutgoingMessageAppConfiguration
|
||||
| EMOutgoingMessageTagWrite
|
||||
| EMOutgoingMessageSidebarShow
|
||||
| EMOutgoingMessageAssistShow
|
||||
| EMOutgoingMessageExoplayerPlayHLS
|
||||
| EMOutgoingMessageExoplayerResize
|
||||
| EMOutgoingMessageExoplayerStop
|
||||
@ -152,6 +161,7 @@ export interface ExternalConfig {
|
||||
canWriteTag: boolean;
|
||||
hasExoPlayer: boolean;
|
||||
canCommissionMatter: boolean;
|
||||
hasAssist: boolean;
|
||||
}
|
||||
|
||||
export class ExternalMessaging {
|
||||
|
@ -567,7 +567,7 @@ class HUIRoot extends LitElement {
|
||||
if (searchParams.edit === "1") {
|
||||
this.lovelace!.setEditMode(true);
|
||||
} else if (searchParams.conversation === "1") {
|
||||
showVoiceCommandDialog(this);
|
||||
showVoiceCommandDialog(this, this.hass);
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
@ -793,7 +793,7 @@ class HUIRoot extends LitElement {
|
||||
}
|
||||
|
||||
private _showVoiceCommandDialog(): void {
|
||||
showVoiceCommandDialog(this);
|
||||
showVoiceCommandDialog(this, this.hass);
|
||||
}
|
||||
|
||||
private _handleEnableEditMode(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||
|
@ -76,7 +76,7 @@ class PanelShoppingList extends LitElement {
|
||||
}
|
||||
|
||||
private _showVoiceCommandDialog(): void {
|
||||
showVoiceCommandDialog(this);
|
||||
showVoiceCommandDialog(this, this.hass);
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user