@@ -65,20 +65,20 @@ Module.register("MMM-OneCallWeather", {
6565 firstEvent : false ,
6666
6767 // Define required CSS files.
68- getStyles ( ) {
68+ getStyles ( ) {
6969 return [ "MMM-OneCallWeather.css" ] ;
7070 } ,
7171
7272 // Define start sequence.
73- start ( ) {
73+ start ( ) {
7474 Log . info ( `Starting module: ${ this . name } ` ) ;
7575 this . forecast = [ ] ;
7676 this . loaded = false ;
7777 this . scheduleUpdate ( this . config . initialLoadDelay ) ;
7878 this . updateTimer = null ;
7979 } ,
8080
81- scheduleUpdate ( delay ) {
81+ scheduleUpdate ( delay ) {
8282 let nextLoad = this . config . updateInterval ;
8383 if ( typeof delay !== "undefined" && delay >= 0 ) {
8484 nextLoad = delay ;
@@ -91,7 +91,7 @@ Module.register("MMM-OneCallWeather", {
9191 } , nextLoad ) ;
9292 } ,
9393
94- updateWeather ( ) {
94+ updateWeather ( ) {
9595 this . sendSocketNotification ( "OPENWEATHER_ONECALL_GET" , {
9696 apikey : this . config . apikey ,
9797 apiVersion : this . config . apiVersion ,
@@ -104,7 +104,7 @@ Module.register("MMM-OneCallWeather", {
104104 } ) ;
105105 } ,
106106
107- socketNotificationReceived ( notification , payload ) {
107+ socketNotificationReceived ( notification , payload ) {
108108 if ( notification === "OPENWEATHER_ONECALL_DATA" ) {
109109 // process weather data
110110 data = payload ;
@@ -115,19 +115,20 @@ Module.register("MMM-OneCallWeather", {
115115 }
116116 } ,
117117
118- processOnecall ( ) {
118+ processOnecall ( ) {
119119 let wsfactor = 2.237 ;
120120 const current = [ ] ;
121121 if ( this . config . windUnits === "kmph" ) {
122122 wsfactor = 3.6 ;
123- } else if ( this . config . windUnits === "ms" ) {
123+ }
124+ else if ( this . config . windUnits === "ms" ) {
124125 wsfactor = 1 ;
125126 }
126127
127128 if ( Object . hasOwn ( data , "current" ) ) {
128129 const currently = {
129130 date : new Date ( ( data . current . dt + data . timezone_offset ) * 1000 ) ,
130- dayOfWeek : new Intl . DateTimeFormat ( config . language , { weekday : "short" } ) . format ( data . current . dt ) ,
131+ dayOfWeek : new Intl . DateTimeFormat ( config . language , { weekday : "short" } ) . format ( data . current . dt ) ,
131132 windSpeed : ( data . current . wind_speed * wsfactor ) . toFixed ( 0 ) ,
132133 windDirection : data . current . wind_deg ,
133134 sunrise : new Date ( ( data . current . sunrise + data . timezone_offset ) * 1000 ) ,
@@ -155,23 +156,25 @@ Module.register("MMM-OneCallWeather", {
155156 let precip = false ;
156157
157158 if (
158- Object . hasOwn ( hour , "rain" ) &&
159- ! Number . isNaN ( hour . rain [ "1h" ] )
159+ Object . hasOwn ( hour , "rain" )
160+ && ! Number . isNaN ( hour . rain [ "1h" ] )
160161 ) {
161162 if ( this . config . units === "imperial" ) {
162163 rain = hour . rain [ "1h" ] / 25.4 ;
163- } else {
164+ }
165+ else {
164166 rain = hour . rain [ "1h" ] ;
165167 }
166168 precip = true ;
167169 }
168170 if (
169- Object . hasOwn ( hour , "snow" ) &&
170- ! Number . isNaN ( hour . snow [ "1h" ] )
171+ Object . hasOwn ( hour , "snow" )
172+ && ! Number . isNaN ( hour . snow [ "1h" ] )
171173 ) {
172174 if ( this . config . units === "imperial" ) {
173175 snow = hour . snow [ "1h" ] / 25.4 ;
174- } else {
176+ }
177+ else {
175178 snow = hour . snow [ "1h" ] ;
176179 }
177180 precip = true ;
@@ -208,19 +211,21 @@ Module.register("MMM-OneCallWeather", {
208211 let precip = false ;
209212
210213 if ( ! Number . isNaN ( day . rain ) ) {
211- const { rain : dayRain } = day ;
214+ const { rain : dayRain } = day ;
212215 if ( this . config . units === "imperial" ) {
213216 rain = dayRain / 25.4 ;
214- } else {
217+ }
218+ else {
215219 rain = dayRain ;
216220 }
217221 precip = true ;
218222 }
219223 if ( ! Number . isNaN ( day . snow ) ) {
220- const { snow : daySnow } = day ;
224+ const { snow : daySnow } = day ;
221225 if ( this . config . units === "imperial" ) {
222226 snow = daySnow / 25.4 ;
223- } else {
227+ }
228+ else {
224229 snow = daySnow ;
225230 }
226231 precip = true ;
@@ -232,7 +237,7 @@ Module.register("MMM-OneCallWeather", {
232237 }
233238
234239 forecastData = {
235- dayOfWeek : new Intl . DateTimeFormat ( config . language , { weekday : "short" } ) . format ( day . dt * 1000 ) ,
240+ dayOfWeek : new Intl . DateTimeFormat ( config . language , { weekday : "short" } ) . format ( day . dt * 1000 ) ,
236241 date : new Date ( ( day . dt + data . timezone_offset ) * 1000 ) ,
237242 sunrise : new Date ( ( day . sunrise + data . timezone_offset ) * 1000 ) ,
238243 sunset : new Date ( ( day . sunset + data . timezone_offset ) * 1000 ) ,
@@ -252,13 +257,13 @@ Module.register("MMM-OneCallWeather", {
252257 }
253258
254259 // Log.debug("forecast is " + JSON.stringify(days));
255- return { current,
260+ return { current,
256261 hours,
257- days} ;
262+ days } ;
258263 } ,
259264
260265 // Override dom generator.
261- getDom ( ) {
266+ getDom ( ) {
262267 const wrapper = document . createElement ( "div" ) ;
263268
264269 if ( this . config . appid === "" ) {
@@ -361,11 +366,13 @@ Module.register("MMM-OneCallWeather", {
361366 const rainCell = document . createElement ( "td" ) ;
362367 if ( Number . isNaN ( dailyForecast . precipitation ) ) {
363368 rainCell . innerHTML = "" ;
364- } else if ( config . units === "imperial" ) {
369+ }
370+ else if ( config . units === "imperial" ) {
365371 rainCell . innerHTML = `${ (
366372 parseFloat ( dailyForecast . precipitation ) / 25.4
367373 ) . toFixed ( 2 ) } in`;
368- } else {
374+ }
375+ else {
369376 rainCell . innerHTML = `${ parseFloat ( dailyForecast . precipitation ) . toFixed ( 1 ) } mm` ;
370377 }
371378 rainCell . className = "align-right bright rain" ;
@@ -448,8 +455,8 @@ Module.register("MMM-OneCallWeather", {
448455 iconRow . appendChild ( iconCell ) ;
449456
450457 if (
451- this . config . decimalSymbol === "" ||
452- this . config . decimalSymbol === " "
458+ this . config . decimalSymbol === ""
459+ || this . config . decimalSymbol === " "
453460 ) {
454461 this . config . decimalSymbol = "." ;
455462 }
@@ -467,10 +474,11 @@ Module.register("MMM-OneCallWeather", {
467474 const minTempCell = document . createElement ( "td" ) ;
468475 if ( this . config . tempUnits === "f" ) {
469476 minTempCell . innerHTML = ` ${ (
470- dailyForecast . minTemperature * ( 9 / 5 ) +
471- 32
477+ dailyForecast . minTemperature * ( 9 / 5 )
478+ + 32
472479 ) . toFixed ( 0 ) } ${ degreeLabel } `;
473- } else {
480+ }
481+ else {
474482 minTempCell . innerHTML = `${ dailyForecast . minTemperature } ${ degreeLabel } ` ;
475483 }
476484 minTempCell . className = "min-temp" ;
@@ -493,11 +501,13 @@ Module.register("MMM-OneCallWeather", {
493501 const rainCell = document . createElement ( "td" ) ;
494502 if ( Number . isNaN ( dailyForecast . precipitation ) ) {
495503 rainCell . innerHTML = "" ;
496- } else if ( config . units === "imperial" ) {
504+ }
505+ else if ( config . units === "imperial" ) {
497506 rainCell . innerHTML = `${ (
498507 parseFloat ( dailyForecast . precipitation ) / 25.4
499508 ) . toFixed ( 2 ) } in`;
500- } else {
509+ }
510+ else {
501511 rainCell . innerHTML = `${ parseFloat ( dailyForecast . precipitation ) . toFixed ( 1 ) } mm` ;
502512 }
503513 rainCell . className = "align-right bright rain" ;
@@ -536,7 +546,7 @@ Module.register("MMM-OneCallWeather", {
536546 } ,
537547
538548 // Helper method to create current weather block (reduces code duplication)
539- createCurrentWeatherBlock ( currentWeather , colspan , degreeLabel ) {
549+ createCurrentWeatherBlock ( currentWeather , colspan , degreeLabel ) {
540550 const table = document . createElement ( "table" ) ;
541551 table . className = this . config . tableClass ;
542552
@@ -558,7 +568,8 @@ Module.register("MMM-OneCallWeather", {
558568 if ( this . config . useBeaufortInCurrent ) {
559569 this . convSpd = this . mph2Beaufort ( currentWeather . windSpeed ) ;
560570 windySpeed . innerHTML = `F${ this . convSpd } ` ;
561- } else {
571+ }
572+ else {
562573 windySpeed . innerHTML = ` ${ currentWeather . windSpeed } ` ;
563574 }
564575 windContainer . appendChild ( windySpeed ) ;
@@ -567,7 +578,8 @@ Module.register("MMM-OneCallWeather", {
567578 const windyDirection = document . createElement ( "sup" ) ;
568579 if ( this . config . showWindDirectionAsArrow ) {
569580 windyDirection . innerHTML = ` <i class="fa fa-long-arrow-down" style="transform:rotate(${ currentWeather . windDirection } deg);"></i> ` ;
570- } else {
581+ }
582+ else {
571583 windyDirection . innerHTML = ` ${ this . cardinalWindDirection ( currentWeather . windDirection ) } ` ;
572584 }
573585 windContainer . appendChild ( windyDirection ) ;
@@ -603,10 +615,11 @@ Module.register("MMM-OneCallWeather", {
603615 currTemperature . className = "large bright" ;
604616 if ( this . config . tempUnits === "f" ) {
605617 currTemperature . innerHTML = ` ${ (
606- currentWeather . temperature * ( 9 / 5 ) +
607- 32
618+ currentWeather . temperature * ( 9 / 5 )
619+ + 32
608620 ) . toFixed ( 0 ) } ${ degreeLabel } `;
609- } else {
621+ }
622+ else {
610623 currTemperature . innerHTML = ` ${ currentWeather . temperature } ${ degreeLabel } ` ;
611624 }
612625
@@ -629,10 +642,11 @@ Module.register("MMM-OneCallWeather", {
629642
630643 if ( this . config . tempUnits === "f" ) {
631644 currFeelsLike . innerHTML = ` ${ (
632- currentWeather . feelsLikeTemp * ( 9 / 5 ) +
633- 32
645+ currentWeather . feelsLikeTemp * ( 9 / 5 )
646+ + 32
634647 ) . toFixed ( 0 ) } ${ degreeLabel } `;
635- } else {
648+ }
649+ else {
636650 const feelsLikeString = this . translate ( "FEELS" ) ;
637651 const feelsLikeText = feelsLikeString . replace ( "{DEGREE}" , `${ currentWeather . feelsLikeTemp } ${ degreeLabel } ` ) ;
638652 currFeelsLike . innerHTML = feelsLikeText ;
@@ -647,11 +661,11 @@ Module.register("MMM-OneCallWeather", {
647661 return table ;
648662 } ,
649663
650- getOrdinal ( bearing ) {
664+ getOrdinal ( bearing ) {
651665 return this . config . labelOrdinals [ Math . round ( bearing * 16 / 360 ) % 16 ] ;
652666 } ,
653667
654- cardinalWindDirection ( windDir ) {
668+ cardinalWindDirection ( windDir ) {
655669 if ( windDir > 11.25 && windDir <= 33.75 ) {
656670 return "NNE" ;
657671 }
@@ -701,7 +715,7 @@ Module.register("MMM-OneCallWeather", {
701715 } ,
702716
703717 // Create a wind badge with centered speed value and compass direction indicator
704- createWindBadge ( speed , directionDeg ) {
718+ createWindBadge ( speed , directionDeg ) {
705719 const container = document . createElement ( "div" ) ;
706720 container . className = "wind-badge" ;
707721
@@ -718,7 +732,7 @@ Module.register("MMM-OneCallWeather", {
718732 return container ;
719733 } ,
720734
721- convertOpenWeatherIdToIcon ( id , openweatherIcon ) {
735+ convertOpenWeatherIdToIcon ( id , openweatherIcon ) {
722736 if ( id >= 200 && id < 300 ) {
723737 // Thunderstorm
724738 return "thunderstorm" ;
@@ -776,7 +790,7 @@ Module.register("MMM-OneCallWeather", {
776790 return false ;
777791 } ,
778792
779- roundValue ( temperature ) {
793+ roundValue ( temperature ) {
780794 const decimals = this . config . roundTemp
781795 ? 0
782796 : 1 ;
@@ -786,7 +800,7 @@ Module.register("MMM-OneCallWeather", {
786800 /*
787801 * Convert the OpenWeatherMap icons to a more usable name.
788802 */
789- convertWeatherType ( weatherType ) {
803+ convertWeatherType ( weatherType ) {
790804 const weatherTypes = {
791805 "01d" : "day-clear-sky" ,
792806 "02d" : "day-few-clouds" ,
@@ -825,7 +839,7 @@ Module.register("MMM-OneCallWeather", {
825839 *
826840 * return number - Windspeed in beaufort.
827841 */
828- mph2Beaufort ( mph ) {
842+ mph2Beaufort ( mph ) {
829843 const kmh = mph * 1.60934 ;
830844 const speeds = [ 1 , 5 , 11 , 19 , 28 , 38 , 49 , 61 , 74 , 88 , 102 , 117 , 1000 ] ;
831845 for ( const beaufort of speeds ) {
0 commit comments