-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MVP voice assist flow #22061
Merged
Merged
Add MVP voice assist flow #22061
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { HassEntity } from "home-assistant-js-websocket"; | ||
import { HomeAssistant } from "../types"; | ||
import { supportsFeature } from "../common/entity/supports-feature"; | ||
|
||
export const enum AssistSatelliteEntityFeature { | ||
ANNOUNCE = 1, | ||
} | ||
|
||
export interface WakeWordInterceptMessage { | ||
wake_word_phrase: string; | ||
} | ||
|
||
export interface WakeWordOption { | ||
id: string; | ||
wake_word: string; | ||
trained_languages: string[]; | ||
} | ||
|
||
export interface AssistSatelliteConfiguration { | ||
active_wake_words: string[]; | ||
available_wake_words: WakeWordOption[]; | ||
max_active_wake_words: number; | ||
pipeline_entity_id: string; | ||
vad_entity_id: string; | ||
} | ||
|
||
export const interceptWakeWord = ( | ||
hass: HomeAssistant, | ||
entity_id: string, | ||
callback: (result: WakeWordInterceptMessage) => void | ||
) => | ||
hass.connection.subscribeMessage(callback, { | ||
type: "assist_satellite/intercept_wake_word", | ||
entity_id, | ||
}); | ||
|
||
export const testAssistSatelliteConnection = ( | ||
hass: HomeAssistant, | ||
entity_id: string | ||
) => | ||
hass.callWS<{ | ||
status: "success" | "timeout"; | ||
}>({ | ||
type: "assist_satellite/test_connection", | ||
entity_id, | ||
}); | ||
|
||
export const assistSatelliteAnnounce = ( | ||
hass: HomeAssistant, | ||
entity_id: string, | ||
message: string | ||
) => | ||
hass.callService("assist_satellite", "announce", { message }, { entity_id }); | ||
|
||
export const fetchAssistSatelliteConfiguration = ( | ||
hass: HomeAssistant, | ||
entity_id: string | ||
) => | ||
hass.callWS<AssistSatelliteConfiguration>({ | ||
type: "assist_satellite/get_configuration", | ||
entity_id, | ||
}); | ||
|
||
export const setWakeWords = ( | ||
hass: HomeAssistant, | ||
entity_id: string, | ||
wake_word_ids: string[] | ||
) => | ||
hass.callWS({ | ||
type: "assist_satellite/set_wake_words", | ||
entity_id, | ||
wake_word_ids, | ||
}); | ||
|
||
export const assistSatelliteSupportsSetupFlow = ( | ||
assistSatelliteEntity: HassEntity | undefined | ||
) => | ||
assistSatelliteEntity && | ||
supportsFeature(assistSatelliteEntity, AssistSatelliteEntityFeature.ANNOUNCE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/dialogs/voice-assistant-setup/show-voice-assistant-setup-dialog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { fireEvent } from "../../common/dom/fire_event"; | ||
|
||
const loadVoiceAssistantSetupDialog = () => | ||
import("./voice-assistant-setup-dialog"); | ||
|
||
export interface VoiceAssistantSetupDialogParams { | ||
deviceId: string; | ||
} | ||
|
||
export const showVoiceAssistantSetupDialog = ( | ||
element: HTMLElement, | ||
dialogParams: VoiceAssistantSetupDialogParams | ||
): void => { | ||
fireEvent(element, "show-dialog", { | ||
dialogTag: "ha-voice-assistant-setup-dialog", | ||
dialogImport: loadVoiceAssistantSetupDialog, | ||
dialogParams: dialogParams, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { css } from "lit"; | ||
import { haStyle } from "../../resources/styles"; | ||
|
||
export const AssistantSetupStyles = [ | ||
haStyle, | ||
css` | ||
:host { | ||
align-items: center; | ||
text-align: center; | ||
min-height: 300px; | ||
max-width: 500px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
height: 100%; | ||
padding: 24px; | ||
box-sizing: border-box; | ||
} | ||
.content { | ||
flex: 1; | ||
} | ||
.content img { | ||
width: 120px; | ||
margin-top: 68px; | ||
margin-bottom: 68px; | ||
} | ||
.footer { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.footer ha-button { | ||
width: 100%; | ||
} | ||
`, | ||
]; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert const enum to regular enum for better compatibility
The
const
keyword on the enum declaration can lead to compatibility issues with bundlers and the 'isolatedModules' mode in TypeScript, as pointed out by the static analysis tool.To address this, please change the enum declaration to a regular enum:
This change ensures better compatibility while maintaining the same functionality.
Tools
Biome