Skip to content

Commit

Permalink
Fix showing options button on conversation agent picker (#20736)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored May 6, 2024
1 parent bc41de0 commit 008c842
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/ha-conversation-agent-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { HomeAssistant } from "../types";
import "./ha-list-item";
import "./ha-select";
import type { HaSelect } from "./ha-select";
import { getExtendedEntityRegistryEntry } from "../data/entity_registry";

const NONE = "__NONE_OPTION__";

Expand Down Expand Up @@ -107,13 +108,23 @@ export class HaConversationAgentPicker extends LitElement {
}

private async _maybeFetchConfigEntry() {
if (!this.value || this.value === "homeassistant") {
if (!this.value || !(this.value in this.hass.entities)) {
this._configEntry = undefined;
return;
}
try {
const regEntry = await getExtendedEntityRegistryEntry(
this.hass,
this.value
);

if (!regEntry.config_entry_id) {
this._configEntry = undefined;
return;
}

this._configEntry = (
await getConfigEntry(this.hass, this.value)
await getConfigEntry(this.hass, regEntry.config_entry_id)
).config_entry;
} catch (err) {
this._configEntry = undefined;
Expand Down

0 comments on commit 008c842

Please sign in to comment.