@@ -78,10 +78,51 @@ export class WeekPlannerCard extends LitElement {
78
78
_hideDaysWithoutEvents ;
79
79
_hideTodayWithoutEvents ;
80
80
_filter ;
81
+ _filterText ;
81
82
_combineSimilarEvents ;
82
83
_showLegend ;
83
84
_actions ;
84
85
86
+ /**
87
+ * Get config element
88
+ *
89
+ * @returns {HTMLElement }
90
+ */
91
+ static getConfigElement ( ) {
92
+ // Create and return an editor element
93
+ return document . createElement ( "week-planner-card-editor" ) ;
94
+ }
95
+
96
+ /**
97
+ * Get stub config
98
+ *
99
+ * @returns { }
100
+ */
101
+ static getStubConfig ( ) {
102
+ return {
103
+ calendars : [ ] ,
104
+ days : 7 ,
105
+ startingDay : 'today' ,
106
+ startingDayOffset : 0 ,
107
+ hideWeekend : false ,
108
+ noCardBackground : false ,
109
+ compact : false ,
110
+ weather : {
111
+ showCondition : true ,
112
+ showTemperature : false ,
113
+ showLowTemperature : false ,
114
+ useTwiceDaily : false ,
115
+ } ,
116
+ locale : 'en' ,
117
+ showLocation : false ,
118
+ hidePastEvents : false ,
119
+ hideDaysWithoutEvents : false ,
120
+ hideTodayWithoutEvents : false ,
121
+ combineSimilarEvents : false ,
122
+ showLegend : false
123
+ } ;
124
+ }
125
+
85
126
/**
86
127
* Get properties
87
128
*
@@ -130,6 +171,7 @@ export class WeekPlannerCard extends LitElement {
130
171
this . _hideDaysWithoutEvents = config . hideDaysWithoutEvents ?? false ;
131
172
this . _hideTodayWithoutEvents = config . hideTodayWithoutEvents ?? false ;
132
173
this . _filter = config . filter ?? false ;
174
+ this . _filterText = config . filterText ?? false ;
133
175
this . _combineSimilarEvents = config . combineSimilarEvents ?? false ;
134
176
this . _showLegend = config . showLegend ?? false ;
135
177
this . _actions = config . actions ?? false ;
@@ -177,6 +219,10 @@ export class WeekPlannerCard extends LitElement {
177
219
Object . assign ( configuration , weatherConfiguration ) ;
178
220
}
179
221
222
+ if ( ! configuration . hasOwnProperty ( 'entity' ) || configuration . entity === null ) {
223
+ return null ;
224
+ }
225
+
180
226
return configuration ;
181
227
}
182
228
@@ -235,7 +281,11 @@ export class WeekPlannerCard extends LitElement {
235
281
${ this . _calendars . map ( ( calendar ) => {
236
282
if ( ! calendar . hideInLegend ) {
237
283
return html `
238
- < li style ="--legend-calendar-color: ${ calendar . color } ">
284
+ < li class ="${ calendar . icon ? 'icon' : 'noIcon' } " style ="--legend-calendar-color: ${ calendar . color } ">
285
+ ${ calendar . icon ?
286
+ html `< ha-icon icon ="${ calendar . icon } "> </ ha-icon > ` :
287
+ ''
288
+ }
239
289
${ calendar . name ?? calendar . entity }
240
290
</ li >
241
291
` ;
@@ -339,26 +389,34 @@ export class WeekPlannerCard extends LitElement {
339
389
< div class ="inner ">
340
390
< div class ="time ">
341
391
${ event . fullDay ?
342
- html `${ this . _language . fullDay } ` :
343
- html `
344
- ${ event . start . toFormat ( this . _timeFormat ) }
345
- ${ event . end ? ' - ' + event . end . toFormat ( this . _timeFormat ) : '' }
346
- `
392
+ html `${ this . _language . fullDay } ` :
393
+ html `
394
+ ${ event . start . toFormat ( this . _timeFormat ) }
395
+ ${ event . end ? ' - ' + event . end . toFormat ( this . _timeFormat ) : '' }
396
+ `
347
397
}
348
398
</ div >
349
399
< div class ="title ">
350
400
${ event . summary }
351
401
</ div >
352
402
${ this . _showLocation && event . location ?
353
- html `
354
- < div class ="location ">
355
- < ha-icon icon ="mdi:map-marker "> </ ha-icon >
356
- ${ event . location }
357
- </ div >
358
- ` :
359
- ''
403
+ html `
404
+ < div class ="location ">
405
+ < ha-icon icon ="mdi:map-marker "> </ ha-icon >
406
+ ${ event . location }
407
+ </ div >
408
+ ` :
409
+ ''
360
410
}
361
411
</ div >
412
+ ${ event . icon ?
413
+ html `
414
+ < div class ="icon ">
415
+ < ha-icon icon ="${ event . icon } "> </ ha-icon >
416
+ </ div >
417
+ ` :
418
+ ''
419
+ }
362
420
</ div >
363
421
`
364
422
}
@@ -523,6 +581,10 @@ export class WeekPlannerCard extends LitElement {
523
581
524
582
let calendarNumber = 0 ;
525
583
this . _calendars . forEach ( calendar => {
584
+ if ( ! calendar . entity || ! this . hass . states [ calendar . entity ] ) {
585
+ return ;
586
+ }
587
+
526
588
if ( ! calendar . name ) {
527
589
calendar = {
528
590
...calendar ,
@@ -616,7 +678,7 @@ export class WeekPlannerCard extends LitElement {
616
678
}
617
679
} else {
618
680
this . _calendarEvents [ eventKey ] = {
619
- summary : event . summary ?? null ,
681
+ summary : this . _filterEventSummary ( event . summary ?? null , calendar ) ,
620
682
description : event . description ?? null ,
621
683
location : event . location ?? null ,
622
684
start : startDate ,
@@ -625,6 +687,7 @@ export class WeekPlannerCard extends LitElement {
625
687
originalEnd : this . _convertApiDate ( event . end ) ,
626
688
fullDay : fullDay ,
627
689
color : calendar . color ?? 'inherit' ,
690
+ icon : calendar . icon ?? null ,
628
691
otherColors : [ ] ,
629
692
calendar : calendar . entity ,
630
693
otherCalendars : [ ] ,
@@ -636,6 +699,22 @@ export class WeekPlannerCard extends LitElement {
636
699
}
637
700
}
638
701
702
+ _filterEventSummary ( summary , calendar ) {
703
+ if ( ! summary ) {
704
+ return '' ;
705
+ }
706
+
707
+ if ( calendar . filterText ) {
708
+ summary = summary . replace ( new RegExp ( calendar . filterText ) , '' ) ;
709
+ }
710
+
711
+ if ( this . _filterText ) {
712
+ summary = summary . replace ( new RegExp ( this . _filterText ) , '' ) ;
713
+ }
714
+
715
+ return summary ;
716
+ }
717
+
639
718
_getEventClass ( startDate , endDate , fullDay ) {
640
719
let classes = [ ] ;
641
720
let now = DateTime . now ( ) ;
0 commit comments