@@ -323,7 +323,8 @@ export const getComponentIcons = async (
323323export const getCategoryIcons = async <
324324 T extends Exclude < IconCategory , "entity" | "entity_component" > ,
325325> (
326- hass : HomeAssistant ,
326+ connection : Connection ,
327+ hassConfig : HomeAssistant [ "config" ] ,
327328 category : T ,
328329 domain ?: string ,
329330 force = false
@@ -334,12 +335,10 @@ export const getCategoryIcons = async <
334335 Record < string , CategoryType [ T ] >
335336 > ;
336337 }
337- resources [ category ] . all = getHassIcons ( hass . connection , category ) . then (
338- ( res ) => {
339- resources [ category ] . domains = res . resources as any ;
340- return res ?. resources as Record < string , CategoryType [ T ] > ;
341- }
342- ) as any ;
338+ resources [ category ] . all = getHassIcons ( connection , category ) . then ( ( res ) => {
339+ resources [ category ] . domains = res . resources as any ;
340+ return res ?. resources as Record < string , CategoryType [ T ] > ;
341+ } ) as any ;
343342 return resources [ category ] . all as Promise < Record < string , CategoryType [ T ] > > ;
344343 }
345344 if ( ! force && domain in resources [ category ] . domains ) {
@@ -351,36 +350,39 @@ export const getCategoryIcons = async <
351350 return resources [ category ] . domains [ domain ] as Promise < CategoryType [ T ] > ;
352351 }
353352 }
354- if ( ! isComponentLoaded ( hass . config , domain ) ) {
353+ if ( ! isComponentLoaded ( hassConfig , domain ) ) {
355354 return undefined ;
356355 }
357- const result = getHassIcons ( hass . connection , category , domain ) ;
356+ const result = getHassIcons ( connection , category , domain ) ;
358357 resources [ category ] . domains [ domain ] = result . then (
359358 ( res ) => res ?. resources [ domain ]
360359 ) as any ;
361360 return resources [ category ] . domains [ domain ] as Promise < CategoryType [ T ] > ;
362361} ;
363362
364363export const getServiceIcons = async (
365- hass : HomeAssistant ,
364+ connection : Connection ,
365+ hassConfig : HomeAssistant [ "config" ] ,
366366 domain ?: string ,
367367 force = false
368368) : Promise < ServiceIcons | Record < string , ServiceIcons > | undefined > =>
369- getCategoryIcons ( hass , "services" , domain , force ) ;
369+ getCategoryIcons ( connection , hassConfig , "services" , domain , force ) ;
370370
371371export const getTriggerIcons = async (
372- hass : HomeAssistant ,
372+ connection : Connection ,
373+ hassConfig : HomeAssistant [ "config" ] ,
373374 domain ?: string ,
374375 force = false
375376) : Promise < TriggerIcons | Record < string , TriggerIcons > | undefined > =>
376- getCategoryIcons ( hass , "triggers" , domain , force ) ;
377+ getCategoryIcons ( connection , hassConfig , "triggers" , domain , force ) ;
377378
378379export const getConditionIcons = async (
379- hass : HomeAssistant ,
380+ connection : Connection ,
381+ hassConfig : HomeAssistant [ "config" ] ,
380382 domain ?: string ,
381383 force = false
382384) : Promise < ConditionIcons | Record < string , ConditionIcons > | undefined > =>
383- getCategoryIcons ( hass , "conditions" , domain , force ) ;
385+ getCategoryIcons ( connection , hassConfig , "conditions" , domain , force ) ;
384386
385387// Cache for sorted range keys
386388const sortedRangeCache = new WeakMap < Record < string , string > , number [ ] > ( ) ;
@@ -578,70 +580,78 @@ export const attributeIcon = async (
578580} ;
579581
580582export const triggerIcon = async (
581- hass : HomeAssistant ,
583+ connection : Connection ,
584+ hassConfig : HomeAssistant [ "config" ] ,
582585 trigger : string
583586) : Promise < string | undefined > => {
584587 let icon : string | undefined ;
585588
586589 const domain = getTriggerDomain ( trigger ) ;
587590 const triggerName = getTriggerObjectId ( trigger ) ;
588591
589- const triggerIcons = await getTriggerIcons ( hass , domain ) ;
592+ const triggerIcons = await getTriggerIcons ( connection , hassConfig , domain ) ;
590593 if ( triggerIcons ) {
591594 const trgrIcon = triggerIcons [ triggerName ] as TriggerIcons [ string ] ;
592595 icon = trgrIcon ?. trigger ;
593596 }
594597 if ( ! icon ) {
595- icon = await domainIcon ( hass . connection , hass . config , domain ) ;
598+ icon = await domainIcon ( connection , hassConfig , domain ) ;
596599 }
597600 return icon ;
598601} ;
599602
600603export const conditionIcon = async (
601- hass : HomeAssistant ,
604+ connection : Connection ,
605+ hassConfig : HomeAssistant [ "config" ] ,
602606 condition : string
603607) : Promise < string | undefined > => {
604608 let icon : string | undefined ;
605609
606610 const domain = getConditionDomain ( condition ) ;
607- const conditionIcons = await getConditionIcons ( hass , domain ) ;
611+ const conditionIcons = await getConditionIcons (
612+ connection ,
613+ hassConfig ,
614+ domain
615+ ) ;
608616 if ( conditionIcons ) {
609617 const conditionName = getConditionObjectId ( condition ) ;
610618 const condIcon = conditionIcons [ conditionName ] as ConditionIcons [ string ] ;
611619 icon = condIcon ?. condition ;
612620 }
613621 if ( ! icon ) {
614- icon = await domainIcon ( hass . connection , hass . config , domain ) ;
622+ icon = await domainIcon ( connection , hassConfig , domain ) ;
615623 }
616624 return icon ;
617625} ;
618626
619627export const serviceIcon = async (
620- hass : HomeAssistant ,
628+ connection : Connection ,
629+ hassConfig : HomeAssistant [ "config" ] ,
621630 service : string
622631) : Promise < string | undefined > => {
623632 let icon : string | undefined ;
624633 const domain = computeDomain ( service ) ;
625634 const serviceName = computeObjectId ( service ) ;
626- const serviceIcons = await getServiceIcons ( hass , domain ) ;
635+ const serviceIcons = await getServiceIcons ( connection , hassConfig , domain ) ;
627636 if ( serviceIcons ) {
628637 const srvceIcon = serviceIcons [ serviceName ] as ServiceIcons [ string ] ;
629638 icon = srvceIcon ?. service ;
630639 }
631640 if ( ! icon ) {
632- icon = await domainIcon ( hass . connection , hass . config , domain ) ;
641+ icon = await domainIcon ( connection , hassConfig , domain ) ;
633642 }
634643 return icon ;
635644} ;
636645
637646export const serviceSectionIcon = async (
638- hass : HomeAssistant ,
647+ connection : Connection ,
648+ hassConfig : HomeAssistant [ "config" ] ,
639649 service : string ,
640650 section : string
641651) : Promise < string | undefined > => {
642652 const domain = computeDomain ( service ) ;
643653 const serviceName = computeObjectId ( service ) ;
644- const serviceIcons = await getServiceIcons ( hass , domain ) ;
654+ const serviceIcons = await getServiceIcons ( connection , hassConfig , domain ) ;
645655 if ( serviceIcons ) {
646656 const srvceIcon = serviceIcons [ serviceName ] as ServiceIcons [ string ] ;
647657 return srvceIcon ?. sections ?. [ section ] ;
0 commit comments