mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix Assist pipeline defaults (#21796)
* Fix Assist pipeline defaults * Always set to NONE if nothing * Rewrite for readability
This commit is contained in:
parent
c416daeb92
commit
11ace6002a
@ -45,15 +45,35 @@ export class HaConversationAgentPicker extends LitElement {
|
|||||||
if (!this._agents) {
|
if (!this._agents) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
const value =
|
let value = this.value;
|
||||||
this.value ??
|
if (!value && this.required) {
|
||||||
(this.required &&
|
// Select Home Assistant conversation agent if it supports the language
|
||||||
(!this.language ||
|
for (const agent of this._agents) {
|
||||||
this._agents
|
if (
|
||||||
.find((agent) => agent.id === "homeassistant")
|
agent.id === "conversation.home_assistant" &&
|
||||||
?.supported_languages.includes(this.language))
|
agent.supported_languages.includes(this.language!)
|
||||||
? "homeassistant"
|
) {
|
||||||
: NONE);
|
value = agent.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
// Select the first agent that supports the language
|
||||||
|
for (const agent of this._agents) {
|
||||||
|
if (
|
||||||
|
agent.supported_languages === "*" &&
|
||||||
|
agent.supported_languages.includes(this.language!)
|
||||||
|
) {
|
||||||
|
value = agent.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
value = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this.label ||
|
.label=${this.label ||
|
||||||
|
@ -16,6 +16,7 @@ import { HomeAssistant } from "../types";
|
|||||||
import "./ha-list-item";
|
import "./ha-list-item";
|
||||||
import "./ha-select";
|
import "./ha-select";
|
||||||
import type { HaSelect } from "./ha-select";
|
import type { HaSelect } from "./ha-select";
|
||||||
|
import { computeDomain } from "../common/entity/compute_domain";
|
||||||
|
|
||||||
const NONE = "__NONE_OPTION__";
|
const NONE = "__NONE_OPTION__";
|
||||||
|
|
||||||
@ -41,13 +42,32 @@ export class HaSTTPicker extends LitElement {
|
|||||||
if (!this._engines) {
|
if (!this._engines) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
const value =
|
|
||||||
this.value ??
|
let value = this.value;
|
||||||
(this.required
|
if (!value && this.required) {
|
||||||
? this._engines.find(
|
for (const entity of Object.values(this.hass.entities)) {
|
||||||
(engine) => engine.supported_languages?.length !== 0
|
if (
|
||||||
)
|
entity.platform === "cloud" &&
|
||||||
: NONE);
|
computeDomain(entity.entity_id) === "stt"
|
||||||
|
) {
|
||||||
|
value = entity.entity_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
for (const sttEngine of this._engines) {
|
||||||
|
if (sttEngine?.supported_languages?.length !== 0) {
|
||||||
|
value = sttEngine.engine_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
value = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this.label ||
|
.label=${this.label ||
|
||||||
|
@ -16,6 +16,7 @@ import { HomeAssistant } from "../types";
|
|||||||
import "./ha-list-item";
|
import "./ha-list-item";
|
||||||
import "./ha-select";
|
import "./ha-select";
|
||||||
import type { HaSelect } from "./ha-select";
|
import type { HaSelect } from "./ha-select";
|
||||||
|
import { computeDomain } from "../common/entity/compute_domain";
|
||||||
|
|
||||||
const NONE = "__NONE_OPTION__";
|
const NONE = "__NONE_OPTION__";
|
||||||
|
|
||||||
@ -44,13 +45,32 @@ export class HaTTSPicker extends LitElement {
|
|||||||
if (!this._engines) {
|
if (!this._engines) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
const value =
|
|
||||||
this.value ??
|
let value = this.value;
|
||||||
(this.required
|
if (!value && this.required) {
|
||||||
? this._engines.find(
|
for (const entity of Object.values(this.hass.entities)) {
|
||||||
(engine) => engine.supported_languages?.length !== 0
|
if (
|
||||||
)
|
entity.platform === "cloud" &&
|
||||||
: NONE);
|
computeDomain(entity.entity_id) === "tts"
|
||||||
|
) {
|
||||||
|
value = entity.entity_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
for (const ttsEngine of this._engines) {
|
||||||
|
if (ttsEngine?.supported_languages?.length !== 0) {
|
||||||
|
value = ttsEngine.engine_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
value = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this.label ||
|
.label=${this.label ||
|
||||||
|
@ -28,6 +28,7 @@ import "./assist-pipeline-detail/assist-pipeline-detail-tts";
|
|||||||
import "./assist-pipeline-detail/assist-pipeline-detail-wakeword";
|
import "./assist-pipeline-detail/assist-pipeline-detail-wakeword";
|
||||||
import "./debug/assist-render-pipeline-events";
|
import "./debug/assist-render-pipeline-events";
|
||||||
import { VoiceAssistantPipelineDetailsDialogParams } from "./show-dialog-voice-assistant-pipeline-detail";
|
import { VoiceAssistantPipelineDetailsDialogParams } from "./show-dialog-voice-assistant-pipeline-detail";
|
||||||
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
|
|
||||||
@customElement("dialog-voice-assistant-pipeline-detail")
|
@customElement("dialog-voice-assistant-pipeline-detail")
|
||||||
export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
||||||
@ -54,15 +55,36 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
if (this._params.pipeline) {
|
if (this._params.pipeline) {
|
||||||
this._data = this._params.pipeline;
|
this._data = this._params.pipeline;
|
||||||
this._preferred = this._params.preferred;
|
this._preferred = this._params.preferred;
|
||||||
} else {
|
return;
|
||||||
this._data = {
|
|
||||||
language: (
|
|
||||||
this.hass.config.language || this.hass.locale.language
|
|
||||||
).substring(0, 2),
|
|
||||||
stt_engine: this._cloudActive ? "cloud" : undefined,
|
|
||||||
tts_engine: this._cloudActive ? "cloud" : undefined,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sstDefault: string | undefined;
|
||||||
|
let ttsDefault: string | undefined;
|
||||||
|
if (this._cloudActive) {
|
||||||
|
for (const entity of Object.values(this.hass.entities)) {
|
||||||
|
if (entity.platform !== "cloud") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (computeDomain(entity.entity_id) === "stt") {
|
||||||
|
sstDefault = entity.entity_id;
|
||||||
|
if (ttsDefault) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (computeDomain(entity.entity_id) === "tts") {
|
||||||
|
ttsDefault = entity.entity_id;
|
||||||
|
if (sstDefault) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._data = {
|
||||||
|
language: (
|
||||||
|
this.hass.config.language || this.hass.locale.language
|
||||||
|
).substring(0, 2),
|
||||||
|
stt_engine: sstDefault,
|
||||||
|
tts_engine: ttsDefault,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user