@@ -68,7 +68,7 @@ class ComfortableEnvironmentCard extends LitElement {
68
68
}
69
69
70
70
public static getStubConfig ( ) : Record < string , unknown > {
71
- return { name : localize ( 'configurator.room_name' ) , temperature_sensor : "sensor.room_temperature" , humidity_sensor : "sensor.room_humidity" , display_precision : 1 , show_index : "ALL" , show_realvalues : "ALL" } ;
71
+ return { name : localize ( 'configurator.room_name' ) , temperature_sensor : "sensor.room_temperature" , humidity_sensor : "sensor.room_humidity" , display_precision : 1 , show_index : "ALL" , show_realvalues : "ALL" , index_showinfo : "ALL" } ;
72
72
}
73
73
74
74
protected calcHI ( tempInF : number , humValue : number ) : number {
@@ -102,8 +102,11 @@ class ComfortableEnvironmentCard extends LitElement {
102
102
}
103
103
104
104
protected calcHIEffects ( hiValue : number ) : number {
105
- let hieffects = 0
105
+ let hieffects = NaN
106
106
switch ( true ) {
107
+ case hiValue < 80 :
108
+ hieffects = 0
109
+ break ;
107
110
case hiValue >= 80 && hiValue <= 90.0 :
108
111
hieffects = 1
109
112
break ;
@@ -125,8 +128,11 @@ class ComfortableEnvironmentCard extends LitElement {
125
128
}
126
129
127
130
protected calcDIEffects ( diValue : number ) : number {
128
- let diEffects = 0
131
+ let diEffects = NaN
129
132
switch ( true ) {
133
+ case diValue <= 10.0 :
134
+ diEffects = 0
135
+ break ;
130
136
case diValue > 10.0 && diValue <= 15.0 :
131
137
diEffects = 1
132
138
break ;
@@ -164,9 +170,10 @@ class ComfortableEnvironmentCard extends LitElement {
164
170
const humSensorStatus = Number ( this . hass . states [ this . config . humidity_sensor ] ?. state ) ;
165
171
const tempSensorUnit = this . hass . states [ this . config . temperature_sensor ] ?. attributes . unit_of_measurement
166
172
const tempSensorUnitInF = this . hass . states [ this . config . temperature_sensor ] ?. attributes . unit_of_measurement === '°F'
167
- const showIndex = this . config . show_index
168
- const showRealValues = this . config . show_realvalues
169
- const display_precision = Number ( this . config . display_precision )
173
+ const showIndex = this . config . show_index || 'ALL'
174
+ const indexInfo = this . config . index_showinfo || 'ALL'
175
+ const showRealValues = this . config . show_realvalues || 'ALL'
176
+ const display_precision = Number ( this . config . display_precision ) || 1
170
177
171
178
const tempCelsiusValue = tempSensorUnitInF ? this . toCelsius ( tempSensorStatus ) : tempSensorStatus
172
179
const tempFarenheitValue = tempSensorUnitInF ? tempSensorStatus : this . toFahrenheit ( tempSensorStatus )
@@ -186,74 +193,108 @@ class ComfortableEnvironmentCard extends LitElement {
186
193
${ this . renderStyle ( ) }
187
194
< ha-card tabindex ="0 ">
188
195
189
- ${ ( this . config . room_name || showRealValues != 'NONE' ) ? html `
190
- < div class =" header " >
191
- < div class ="name ">
192
- ${ this . config . room_name }
193
- </ div >
194
- ${ ( showRealValues != 'NONE' ) ? html `
195
- < div class =" header_icons " >
196
- ${ ( showRealValues == 'ALL' || showRealValues == 'TEMPERATURE' ) ? html `
197
- < div class =" temp " >
198
- ${ tempSensorStatus . toFixed ( display_precision ) } ${ tempSensorUnit }
199
- < div class =" icon " >
200
- < svg preserveAspectRatio =" xMidYMid meet " focusable =" false " role =" img " aria-hidden =" true " viewBox =" 0 0 24 24 " style =" fill: var(--state- icon-color); vertical-align: sub; ">
201
- < g >
202
- < path class =" primary-path " d =" ${ mdiThermometer } " / >
203
- </ g >
204
- </ svg >
205
- </ div >
196
+ < div class =" header " >
197
+
198
+ < div class ="name ">
199
+ ${ this . config . room_name }
200
+ </ div >
201
+
202
+ ${ ( showRealValues != 'NONE' ) ? html `
203
+ < div class =" header_icons " >
204
+ ${ ( showRealValues == 'ALL' || showRealValues == 'TEMPERATURE' ) ? html `
205
+ < div class =" temp " >
206
+ ${ tempSensorStatus . toFixed ( display_precision ) } ${ tempSensorUnit }
207
+ < div class =" icon ">
208
+ < svg preserveAspectRatio =" xMidYMid meet " focusable =" false " role =" img " aria-hidden =" true " viewBox =" 0 0 24 24 " style =" fill: var(--state-icon-color); vertical-align: sub; " >
209
+ < g >
210
+ < path class =" primary-path " d =" ${ mdiThermometer } " / >
211
+ </ g >
212
+ </ svg >
206
213
</ div >
207
- ` :`` }
208
- ${ ( showRealValues == 'ALL' || showRealValues == 'HUMIDITY' ) ?html `
209
- < div class ="hum ">
210
- ${ humSensorStatus . toFixed ( display_precision ) } %
211
- < div class ="icon ">
212
- < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
213
- < g >
214
- < path class ="primary-path " d ="${ mdiWaterPercent } " />
215
- </ g >
216
- </ svg >
217
- </ div >
214
+ </ div >
215
+ ` :`` }
216
+
217
+ ${ ( showRealValues == 'ALL' || showRealValues == 'HUMIDITY' ) ?html `
218
+ < div class ="hum ">
219
+ ${ humSensorStatus . toFixed ( display_precision ) } %
220
+ < div class ="icon ">
221
+ < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
222
+ < g >
223
+ < path class ="primary-path " d ="${ mdiWaterPercent } " />
224
+ </ g >
225
+ </ svg >
218
226
</ div >
219
- ` :`` }
220
- </ div >
227
+ </ div >
221
228
` :`` }
222
- </ div >
223
- ` :`` }
229
+ </ div >
230
+ ` :`` }
231
+
232
+ </ div >
224
233
225
234
< div class ="info ">
226
235
227
236
${ ( showIndex == 'ALL' || showIndex == 'HI' ) ?html `
228
- < div class ="comfort-env-text ">
229
- < div class ="icon ">
230
- < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
231
- < g >
232
- < path class ="primary-path " d ="${ mdiSunThermometer } " />
233
- </ g >
234
- </ svg >
237
+ ${ ( indexInfo != 'NONE' ) ?html `
238
+ < div class ="comfort-env-text ">
239
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON' || indexInfo == 'ICON_AND_NAME' || indexInfo == 'ICON_AND_TEXT' ) ?html `
240
+ < div class ="icon ">
241
+ < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
242
+ < g >
243
+ < path class ="primary-path " d ="${ mdiSunThermometer } " />
244
+ </ g >
245
+ </ svg >
246
+ </ div >
247
+ ` :`` }
248
+ ${ ( indexInfo != 'ICON' ) ?html `
249
+ < div class ="effects ">
250
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON_AND_NAME' || indexInfo == 'NAME' || indexInfo == 'NAME_AND_TEXT' ) ?html `
251
+ ${ localize ( 'common.hi' ) } : ${ HI } ${ tempSensorUnit }
252
+ ` :`` }
253
+ ${ ( indexInfo == 'ALL' || indexInfo == 'NAME_AND_TEXT' ) ?html `
254
+ -
255
+ ` :`` }
256
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON_AND_TEXT' || indexInfo == 'TEXT' || indexInfo == 'NAME_AND_TEXT' ) ?html `
257
+ ${ ! Number . isNaN ( HIeffects ) ?localize ( 'states.hi.' + [ HIeffects ] ) :'---' }
258
+ ` :`` }
259
+ </ div >
260
+ ` :`` }
235
261
</ div >
236
- < div class ="effects "> ${ localize ( 'common.hi' ) } : ${ HI } ${ tempSensorUnit } - ${ localize ( 'states.hi.' + [ HIeffects ] ) } </ div >
237
- </ div >
238
- < div class ="color-range-container ">
262
+ ` :`` }
263
+ < div class ="color-range-container ${ indexInfo == 'NONE' ?' collapsed' :'' } ">
239
264
< div class ="color-range-gradient " style ="background: linear-gradient(90deg, rgb(254, 240, 217) 0%, rgb(253, 204, 138) 28%, rgb(252, 141, 89) 42%, rgb(227, 74, 51) 66%, rgb(179, 0, 0) 100%); " >
240
- < li class ="value-box " style ="margin-left: max(0%,calc(${ this . calcRange ( 0 , 100 , tempSensorUnitInF ?76 :23 , tempSensorUnitInF ?132 :57 , HI ) } % - 46px)) "> ${ HI } </ li >
265
+ < div class ="value-box " style ="margin-left: max(0%,calc(${ this . calcRange ( 0 , 100 , tempSensorUnitInF ?76 :23 , tempSensorUnitInF ?132 :57 , HI ) } % - 46px)) "> ${ HI } </ div >
241
266
</ div >
242
267
</ div >
243
268
` :`` }
244
269
245
270
${ ( showIndex == 'ALL' || showIndex == 'DI' ) ?html `
246
- < div class ="comfort-env-text ">
247
- < div class ="icon ">
248
- < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
249
- < g >
250
- < path class ="primary-path " d ="${ mdiThermometerLines } " />
251
- </ g >
252
- </ svg >
253
- </ div >
254
- < div class ="effects "> ${ localize ( 'common.di' ) } : ${ DI } - ${ localize ( 'states.di.' + [ DIeffects ] ) } </ div >
271
+ ${ ( indexInfo != 'NONE' ) ?html `
272
+ < div class ="comfort-env-text ">
273
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON' || indexInfo == 'ICON_AND_NAME' || indexInfo == 'ICON_AND_TEXT' ) ?html `
274
+ < div class ="icon ">
275
+ < svg preserveAspectRatio ="xMidYMid meet " focusable ="false " role ="img " aria-hidden ="true " viewBox ="0 0 24 24 " style ="fill: var(--state-icon-color); vertical-align: sub; ">
276
+ < g >
277
+ < path class ="primary-path " d ="${ mdiThermometerLines } " />
278
+ </ g >
279
+ </ svg >
280
+ </ div >
281
+ ` :`` }
282
+ ${ ( indexInfo != 'ICON' ) ?html `
283
+ < div class ="effects ">
284
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON_AND_NAME' || indexInfo == 'NAME' || indexInfo == 'NAME_AND_TEXT' ) ?html `
285
+ ${ localize ( 'common.di' ) } : ${ DI }
286
+ ` :`` }
287
+ ${ ( indexInfo == 'ALL' || indexInfo == 'NAME_AND_TEXT' ) ?html `
288
+ -
289
+ ` :`` }
290
+ ${ ( indexInfo == 'ALL' || indexInfo == 'ICON_AND_TEXT' || indexInfo == 'TEXT' || indexInfo == 'NAME_AND_TEXT' ) ?html `
291
+ ${ ! Number . isNaN ( DIeffects ) ?localize ( 'states.di.' + [ DIeffects ] ) :'---' }
292
+ ` :`` }
293
+ </ div >
294
+ ` :`` }
255
295
</ div >
256
- < div class ="color-range-container ">
296
+ ` :`` }
297
+ < div class ="color-range-container ${ indexInfo == 'NONE' ?' collapsed' :'' } ">
257
298
< div class ="color-range-gradient " style ="background: linear-gradient(90deg,rgb(5, 112, 176) 0%,rgb(116, 169, 207)12%,rgb(189, 201, 225) 32%,rgb(241, 238, 246) 44%,rgb(254, 240, 217) 56%,rgb(253, 204, 138) 68%,rgb(252, 141, 89) 80%,rgb(227, 74, 51) 88%,rgb(179, 0, 0) 100%); " >
258
299
< div class ="value-box " style ="margin-left: max(0%,calc(${ this . calcRange ( 0 , 100 , 8 , 34 , DI ) } % - 46px)) "> ${ DI } </ div >
259
300
</ div >
@@ -283,13 +324,16 @@ class ComfortableEnvironmentCard extends LitElement {
283
324
.color-range-container {
284
325
display : flex;
285
326
}
327
+ .collapsed {
328
+ margin-top : 2% ;
329
+ }
286
330
.color-range-gradient {
287
331
width : 100% ;
288
332
border-radius : 5px ;
289
333
margin : 0 10px 10px ;
290
334
}
291
335
.value-box {
292
- border : solid 3 px # 000 ;
336
+ border : solid 2 px # 000 ;
293
337
border-radius : 10px ;
294
338
padding : 3px ;
295
339
width : 32px ;
@@ -303,15 +347,18 @@ class ComfortableEnvironmentCard extends LitElement {
303
347
margin : 0 10px 0 ;
304
348
padding : 5px 0 5px ;
305
349
text-align : left;
306
- line-height : var (--mdc-icon-size );
350
+ line-height : var (--mdc-icon-size , 8 px );
307
351
}
308
352
.info {
309
353
margin-top : -4px ;
310
354
padding-bottom : 1% ;
311
355
}
356
+ .effects {
357
+ display : inline;
358
+ }
312
359
.header {
313
360
display : flex;
314
- padding : 0 2% 0 ;
361
+ padding : 1 % 2% 0 ;
315
362
justify-content : space-between;
316
363
font-weight : 500 ;
317
364
margin-bottom : 1% ;
@@ -328,8 +375,8 @@ class ComfortableEnvironmentCard extends LitElement {
328
375
}
329
376
.icon {
330
377
display : inline-block;
331
- width : var (--mdc-icon-size );
332
- height : var (--mdc-icon-size );
378
+ width : var (--mdc-icon-size , 24 px );
379
+ height : var (--mdc-icon-size , 24 px );
333
380
}
334
381
</ style >
335
382
` ;
0 commit comments