Skip to content

Commit

Permalink
Hide deprecated stt/tts engines, use name provided by core (#21805)
Browse files Browse the repository at this point in the history
* Hide deprecated stt/tts engines, use name provided by core

* Update ha-tts-picker.ts
  • Loading branch information
bramkragten authored Aug 27, 2024
1 parent 9bde0e8 commit 6b99cda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/components/ha-stt-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { computeDomain } from "../common/entity/compute_domain";

const NONE = "__NONE_OPTION__";

const NAME_MAP = { cloud: "Home Assistant Cloud" };

@customElement("ha-stt-picker")
export class HaSTTPicker extends LitElement {
@property() public value?: string;
Expand Down Expand Up @@ -86,12 +84,15 @@ export class HaSTTPicker extends LitElement {
</ha-list-item>`
: nothing}
${this._engines.map((engine) => {
let label = engine.engine_id;
if (engine.deprecated && engine.engine_id !== value) {
return nothing;
}
let label: string;
if (engine.engine_id.includes(".")) {
const stateObj = this.hass!.states[engine.engine_id];
label = stateObj ? computeStateName(stateObj) : engine.engine_id;
} else if (engine.engine_id in NAME_MAP) {
label = NAME_MAP[engine.engine_id];
} else {
label = engine.name || engine.engine_id;
}
return html`<ha-list-item
.value=${engine.engine_id}
Expand Down
14 changes: 6 additions & 8 deletions src/components/ha-tts-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import { computeDomain } from "../common/entity/compute_domain";

const NONE = "__NONE_OPTION__";

const NAME_MAP = {
cloud: "Home Assistant Cloud",
google_translate: "Google Translate",
};

@customElement("ha-tts-picker")
export class HaTTSPicker extends LitElement {
@property() public value?: string;
Expand Down Expand Up @@ -89,12 +84,15 @@ export class HaTTSPicker extends LitElement {
</ha-list-item>`
: nothing}
${this._engines.map((engine) => {
let label = engine.engine_id;
if (engine.deprecated && engine.engine_id !== value) {
return nothing;
}
let label: string;
if (engine.engine_id.includes(".")) {
const stateObj = this.hass!.states[engine.engine_id];
label = stateObj ? computeStateName(stateObj) : engine.engine_id;
} else if (engine.engine_id in NAME_MAP) {
label = NAME_MAP[engine.engine_id];
} else {
label = engine.name || engine.engine_id;
}
return html`<ha-list-item
.value=${engine.engine_id}
Expand Down
2 changes: 2 additions & 0 deletions src/data/stt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface SpeechMetadata {
export interface STTEngine {
engine_id: string;
supported_languages?: string[];
name?: string;
deprecated: boolean;
}

export const listSTTEngines = (
Expand Down
2 changes: 2 additions & 0 deletions src/data/tts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { HomeAssistant } from "../types";
export interface TTSEngine {
engine_id: string;
supported_languages?: string[];
name?: string;
deprecated: boolean;
}

export interface TTSVoice {
Expand Down

0 comments on commit 6b99cda

Please sign in to comment.