@@ -5,8 +5,8 @@ import { customElement, property, state } from "lit/decorators";
55import { fireEvent } from "../common/dom/fire_event" ;
66import { stopPropagation } from "../common/dom/stop_propagation" ;
77import { debounce } from "../common/util/debounce" ;
8- import type { ConfigEntry } from "../data/config_entries" ;
9- import { getConfigEntry } from "../data/config_entries" ;
8+ import type { ConfigEntry , SubEntry } from "../data/config_entries" ;
9+ import { getConfigEntry , getSubEntries } from "../data/config_entries" ;
1010import type { Agent } from "../data/conversation" ;
1111import { listAgents } from "../data/conversation" ;
1212import { fetchIntegrationManifest } from "../data/integration" ;
@@ -16,6 +16,7 @@ import "./ha-list-item";
1616import "./ha-select" ;
1717import type { HaSelect } from "./ha-select" ;
1818import { getExtendedEntityRegistryEntry } from "../data/entity_registry" ;
19+ import { showSubConfigFlowDialog } from "../dialogs/config-flow/show-dialog-sub-config-flow" ;
1920
2021const NONE = "__NONE_OPTION__" ;
2122
@@ -37,6 +38,8 @@ export class HaConversationAgentPicker extends LitElement {
3738
3839 @state ( ) private _configEntry ?: ConfigEntry ;
3940
41+ @state ( ) private _subConfigEntry ?: SubEntry ;
42+
4043 protected render ( ) {
4144 if ( ! this . _agents ) {
4245 return nothing ;
@@ -101,7 +104,11 @@ export class HaConversationAgentPicker extends LitElement {
101104 ${ agent . name }
102105 </ ha- lis t- item> `
103106 ) } </ ha- select
104- > ${ this . _configEntry ?. supports_options
107+ > ${ ( this . _subConfigEntry &&
108+ this . _configEntry ?. supported_subentry_types [
109+ this . _subConfigEntry . subentry_type
110+ ] ?. supports_reconfigure ) ||
111+ this . _configEntry ?. supports_options
105112 ? html `<ha- icon- butto n
106113 .path = ${ mdiCog }
107114 @click = ${ this . _openOptionsFlow }
@@ -142,8 +149,17 @@ export class HaConversationAgentPicker extends LitElement {
142149 this . _configEntry = (
143150 await getConfigEntry ( this . hass , regEntry . config_entry_id )
144151 ) . config_entry ;
152+
153+ if ( ! regEntry . config_subentry_id ) {
154+ this . _subConfigEntry = undefined ;
155+ } else {
156+ this . _subConfigEntry = (
157+ await getSubEntries ( this . hass , regEntry . config_entry_id )
158+ ) . find ( ( entry ) => entry . subentry_id === regEntry . config_subentry_id ) ;
159+ }
145160 } catch ( _err ) {
146161 this . _configEntry = undefined ;
162+ this . _subConfigEntry = undefined ;
147163 }
148164 }
149165
@@ -182,6 +198,25 @@ export class HaConversationAgentPicker extends LitElement {
182198 if ( ! this . _configEntry ) {
183199 return ;
184200 }
201+
202+ if (
203+ this . _subConfigEntry &&
204+ this . _configEntry . supported_subentry_types [
205+ this . _subConfigEntry . subentry_type
206+ ] ?. supports_reconfigure
207+ ) {
208+ showSubConfigFlowDialog (
209+ this ,
210+ this . _configEntry ,
211+ this . _subConfigEntry . subentry_type ,
212+ {
213+ startFlowHandler : this . _configEntry . entry_id ,
214+ subEntryId : this . _subConfigEntry . subentry_id ,
215+ }
216+ ) ;
217+ return ;
218+ }
219+
185220 showOptionsFlowDialog ( this , this . _configEntry , {
186221 manifest : await fetchIntegrationManifest (
187222 this . hass ,
0 commit comments