11import { mdiHelpCircle , mdiStarFourPoints } from "@mdi/js" ;
22import { css , html , LitElement } from "lit" ;
3+ import type { HassEntity } from "home-assistant-js-websocket" ;
34import { customElement , property , state } from "lit/decorators" ;
45import { isComponentLoaded } from "../../../common/config/is_component_loaded" ;
56import type { HaProgressButton } from "../../../components/buttons/ha-progress-button" ;
@@ -8,13 +9,23 @@ import type { HaEntityPicker } from "../../../components/entity/ha-entity-picker
89import "../../../components/ha-card" ;
910import "../../../components/ha-settings-row" ;
1011import {
12+ AITaskEntityFeature ,
1113 fetchAITaskPreferences ,
1214 saveAITaskPreferences ,
1315 type AITaskPreferences ,
1416} from "../../../data/ai_task" ;
1517import type { HomeAssistant } from "../../../types" ;
1618import { brandsUrl } from "../../../util/brands-url" ;
1719import { documentationUrl } from "../../../util/documentation-url" ;
20+ import { computeDomain } from "../../../common/entity/compute_domain" ;
21+ import { supportsFeature } from "../../../common/entity/supports-feature" ;
22+
23+ const filterGenData = ( entity : HassEntity ) =>
24+ computeDomain ( entity . entity_id ) === "ai_task" &&
25+ supportsFeature ( entity , AITaskEntityFeature . GENERATE_DATA ) ;
26+ const filterGenImage = ( entity : HassEntity ) =>
27+ computeDomain ( entity . entity_id ) === "ai_task" &&
28+ supportsFeature ( entity , AITaskEntityFeature . GENERATE_IMAGE ) ;
1829
1930@customElement ( "ai-task-pref" )
2031export class AITaskPref extends LitElement {
@@ -26,6 +37,8 @@ export class AITaskPref extends LitElement {
2637
2738 private _gen_data_entity_id ?: string | null ;
2839
40+ private _gen_image_entity_id ?: string | null ;
41+
2942 protected firstUpdated ( changedProps ) {
3043 super . firstUpdated ( changedProps ) ;
3144 if ( ! this . hass || ! isComponentLoaded ( this . hass , "ai_task" ) ) {
@@ -90,7 +103,27 @@ export class AITaskPref extends LitElement {
90103 isComponentLoaded ( this . hass , "ai_task" ) }
91104 .value = ${ this . _gen_data_entity_id ||
92105 this . _prefs ?. gen_data_entity_id }
93- .includeDomains = ${ [ "ai_task" ] }
106+ .entityFilter = ${ filterGenData }
107+ @value-changed = ${ this . _handlePrefChange }
108+ > </ ha- entity- picker>
109+ </ ha- settings- row>
110+ <ha- settings- row .narrow = ${ this . narrow } >
111+ <span slot= "heading" >
112+ ${ this . hass ! . localize ( "ui.panel.config.ai_task.gen_image_header" ) }
113+ </ span>
114+ <span slot= "description" >
115+ ${ this . hass ! . localize (
116+ "ui.panel.config.ai_task.gen_image_description"
117+ ) }
118+ </ span>
119+ <ha- entity- picker
120+ data- name= "gen_image_entity_id"
121+ .hass = ${ this . hass }
122+ .disabled = ${ this . _prefs === undefined &&
123+ isComponentLoaded ( this . hass , "ai_task" ) }
124+ .value = ${ this . _gen_image_entity_id ||
125+ this . _prefs ?. gen_image_entity_id }
126+ .entityFilter = ${ filterGenImage }
94127 @value-changed = ${ this . _handlePrefChange }
95128 > </ ha- entity- picker>
96129 </ ha- settings- row>
@@ -121,6 +154,7 @@ export class AITaskPref extends LitElement {
121154 const oldPrefs = this . _prefs ;
122155 const update : Partial < AITaskPreferences > = {
123156 gen_data_entity_id : this . _gen_data_entity_id ,
157+ gen_image_entity_id : this . _gen_image_entity_id ,
124158 } ;
125159 this . _prefs = { ...this . _prefs ! , ...update } ;
126160 try {
0 commit comments