@@ -3,15 +3,16 @@ import styles from "bundle-text:./entity-editor.css";
33import { CSSResult , html , LitElement , TemplateResult , unsafeCSS } from "lit" ;
44import { customElement , property , state } from "lit/decorators.js" ;
55import { repeat } from "lit/directives/repeat" ;
6- import { fireEvent } from "../functions/config" ;
76import { HomeAssistant } from "custom-card-helpers" ;
87import { EntitiesRowConfig } from "../structs/config" ;
98import localize from "../localization/localize" ;
9+ import { fireEvent } from "../functions/events" ;
10+ import { getEntityName } from "../functions/config" ;
1011
1112@customElement ( 'today-card-entities-editor' )
1213export class TodayCardEntitiesEditor extends LitElement {
1314 @property ( { attribute : false } ) public hass ! : HomeAssistant ;
14- @state ( ) private entities : EntitiesRowConfig [ ] = [ ] ;
15+ @state ( ) public entities : EntitiesRowConfig [ ] = [ ] ;
1516
1617 static get styles ( ) : CSSResult {
1718 return unsafeCSS ( styles ) ;
@@ -31,7 +32,7 @@ export class TodayCardEntitiesEditor extends LitElement {
3132 ( entity , index ) => html `
3233 < div class ="entity ">
3334 < div class ="details ">
34- < span class ="name "> Name </ span >
35+ < span class ="name "> ${ getEntityName ( entity . entity ) } </ span >
3536 < span class ="id "> ${ entity . entity } </ span >
3637 </ div >
3738 < ha-color-picker
@@ -72,22 +73,18 @@ export class TodayCardEntitiesEditor extends LitElement {
7273 const value = event . detail . value ;
7374
7475 const newEntities = this . entities . concat ( ) ;
75- newEntities [ index ] = {
76- entity : newEntities [ index ] . entity ,
77- color : value ,
78- } ;
76+ newEntities [ index ] = { ...newEntities [ index ] , color : value } ;
7977
8078 fireEvent ( this , "entities-changed" , { entities : newEntities } ) ;
8179 }
8280
8381 private addRow ( event : Event ) : void {
84- // @ts -expect-error
85- const value = event . detail . value ;
86- if ( value === "" ) {
82+ const entityId = event . detail . value ;
83+ if ( entityId === "" ) {
8784 return ;
8885 }
8986
90- const newEntities = this . entities . concat ( { entity : value , color : "" } ) ;
87+ const newEntities : EntitiesRowConfig [ ] = this . entities . concat ( { entity : entityId } ) ;
9188
9289 // @ts -expect-error
9390 event . target . value = "" ;
0 commit comments