jclarke0000 / MMM-DarkSkyForecast

Magic Mirror module to display weather information using the Dark Sky API
84 stars 68 forks source link

Display UV index? #21

Closed SokolovskiR closed 2 years ago

SokolovskiR commented 4 years ago

This module looks awsome! I wanted to ask if there is a way to display UV index for current weather?

esmoyer commented 4 years ago

So I am just starting to learn JS but I figured out how to add in SR/SS times (and pretty much any other). Though it does kinda bastardized the code until I learn more and figure out all the styling and adding in new divs and such.

Basically I edited the DarkSkyForecast.js file and added what I wanted from here: https://darksky.net/dev/docs#forecast-request to the summary in this area:

processWeatherData: function() {

    var summary;
    if (this.config.concise) {
      summary = this.weatherData.hourly ? this.weatherData.hourly.summary : this.weatherData.currently.summary;
    } else {
      summary = (this.weatherData.minutely ? this.weatherData.minutely.summary : this.weatherData.currently.summary + ".") + " " +
        (this.weatherData.hourly ? this.weatherData.hourly.summary + " " : "") +
        (this.weatherData.daily ? this.weatherData.daily.summary : "") + " | " + "Sunrise: " + moment(new Date(this.weatherData.daily.data[0].sunriseTime * 1000)).format("LT") +
        " | Sunset: " + moment(new Date(this.weatherData.daily.data[0].sunsetTime * 1000)).format("LT") + " | " + 
        "Humidity: " + this.weatherData.currently.humidity * 100 + "%" + " | Dew Point: " + Math.round(this.weatherData.currently.dewPoint) + "°";
    }

This gave me the data I wanted, appended to the summary data. So it doesn't look the prettiest, but works until I learn more. Hopefully this helps you.

2020-02-07 09_52_42-Magic Mirror

SokolovskiR commented 4 years ago

So I am just starting to learn JS but I figured out how to add in SR/SS times (and pretty much any other). Though it does kinda bastardized the code until I learn more and figure out all the styling and adding in new divs and such. ...

@esmoyer Thanks! I‘m already using additional module for UV index. However interesting to try something new by chance.