jclarke0000 / MMM-DarkSkyForecast

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

Can You Add Humidity? #7

Open revere521 opened 5 years ago

revere521 commented 5 years ago

Hello - this is great! I've been looking for a module that incorporated a daily forecast with an hourly ever since the Weather Underground API went down - this is Awesome and looks great.

I'd like to ask for a feature when you are able - can you add humidity? At least to the current conditions at the top?

RafaelCota commented 5 years ago

I'm using this module and it's great. I have the need to see the weather conditions for several locations and I tried to use MMM-Carousel to be able to scroll the same module with different locations, but no luck. I was wondering if I can do it directly in this module, like putting in the config section several locations and make the module display them one by one in the same position with a programmable interval.

Thank you in advanced for your help.

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