1
- const LitElement = customElements . get ( "ha-panel-lovelace" ) ? Object . getPrototypeOf ( customElements . get ( "ha-panel-lovelace" ) ) : Object . getPrototypeOf ( customElements . get ( "hc-lovelace" ) ) ;
1
+ const LitElement = customElements . get ( "ha-panel-lovelace" )
2
+ ? Object . getPrototypeOf ( customElements . get ( "ha-panel-lovelace" ) )
3
+ : Object . getPrototypeOf ( customElements . get ( "hc-lovelace" ) ) ;
2
4
const html = LitElement . prototype . html ;
3
5
const css = LitElement . prototype . css ;
4
6
@@ -96,9 +98,24 @@ class WeatherCard extends LitElement {
96
98
} ;
97
99
}
98
100
99
- static async getConfigElement ( ) {
100
- await import ( "./weather-card-editor.js" ) ;
101
- return document . createElement ( "weather-card-editor" ) ;
101
+ static getConfigForm ( ) {
102
+ return {
103
+ schema : [
104
+ {
105
+ name : "entity" ,
106
+ required : true ,
107
+ selector : { entity : { domain : "weather" } } ,
108
+ } ,
109
+ {
110
+ name : "name" ,
111
+ selector : { text : { } } ,
112
+ } ,
113
+ { name : "current" , selector : { boolean : { } } } ,
114
+ { name : "details" , selector : { boolean : { } } } ,
115
+ { name : "forecast" , selector : { boolean : { } } } ,
116
+ { name : "hourly_forecast" , selector : { boolean : { } } } ,
117
+ ] ,
118
+ } ;
102
119
}
103
120
104
121
static getStubConfig ( hass , unusedEntities , allEntities ) {
@@ -150,7 +167,9 @@ class WeatherCard extends LitElement {
150
167
return html `
151
168
<ha- card @click = "${ this . _handleClick } " >
152
169
${ this . _config . current !== false ? this . renderCurrent ( stateObj ) : "" }
153
- ${ this . _config . details !== false ? this . renderDetails ( stateObj , lang ) : "" }
170
+ ${ this . _config . details !== false
171
+ ? this . renderDetails ( stateObj , lang )
172
+ : "" }
154
173
${ this . _config . forecast !== false
155
174
? this . renderForecast ( stateObj . attributes . forecast , lang )
156
175
: "" }
@@ -190,14 +209,20 @@ class WeatherCard extends LitElement {
190
209
let next_setting ;
191
210
192
211
if ( sun ) {
193
- next_rising = new Date ( sun . attributes . next_rising ) . toLocaleTimeString ( lang , {
194
- hour : "2-digit" ,
195
- minute : "2-digit" ,
196
- } ) ;
197
- next_setting = new Date ( sun . attributes . next_setting ) . toLocaleTimeString ( lang , {
198
- hour : "2-digit" ,
199
- minute : "2-digit" ,
200
- } ) ;
212
+ next_rising = new Date ( sun . attributes . next_rising ) . toLocaleTimeString (
213
+ lang ,
214
+ {
215
+ hour : "2-digit" ,
216
+ minute : "2-digit" ,
217
+ }
218
+ ) ;
219
+ next_setting = new Date ( sun . attributes . next_setting ) . toLocaleTimeString (
220
+ lang ,
221
+ {
222
+ hour : "2-digit" ,
223
+ minute : "2-digit" ,
224
+ }
225
+ ) ;
201
226
}
202
227
203
228
this . numberElements ++ ;
@@ -219,15 +244,11 @@ class WeatherCard extends LitElement {
219
244
<li>
220
245
<ha- icon icon= "mdi:gauge" > </ ha- icon>
221
246
${ stateObj . attributes . pressure }
222
- <span class= "unit" >
223
- ${ this . getUnit ( "air_pressure" ) }
224
- </ span>
247
+ <span class= "unit" > ${ this . getUnit ( "air_pressure" ) } </ span>
225
248
</ li>
226
249
<li>
227
250
<ha- icon icon= "mdi:weather-fog" > </ ha- icon> ${ stateObj . attributes
228
- . visibility } <span class= "unit" >
229
- ${ this . getUnit ( "length" ) }
230
- </ span>
251
+ . visibility } <span class= "unit" > ${ this . getUnit ( "length" ) } </ span>
231
252
</ li>
232
253
${ next_rising
233
254
? html `
@@ -298,7 +319,8 @@ class WeatherCard extends LitElement {
298
319
daily . precipitation !== null
299
320
? html `
300
321
<div class= "precipitation" >
301
- ${ Math . round ( daily . precipitation * 10 ) / 10 } ${ this . getUnit ( "precipitation" ) }
322
+ ${ Math . round ( daily . precipitation * 10 ) / 10 }
323
+ ${ this . getUnit ( "precipitation" ) }
302
324
</ div>
303
325
`
304
326
: "" }
@@ -307,7 +329,8 @@ class WeatherCard extends LitElement {
307
329
daily . precipitation_probability !== null
308
330
? html `
309
331
<div class= "precipitation_probability" >
310
- ${ Math . round ( daily . precipitation_probability ) } ${ this . getUnit ( "precipitation_probability" ) }
332
+ ${ Math . round ( daily . precipitation_probability ) }
333
+ ${ this . getUnit ( "precipitation_probability" ) }
311
334
</ div>
312
335
`
313
336
: "" }
0 commit comments