jclarke0000 / MMM-OpenWeatherForecast

Magic Mirror weather module using OpenWeather API
42 stars 25 forks source link

Incorrect Current/Hourly Time & Temperature Conversion #3

Open nitewing76 opened 3 years ago

nitewing76 commented 3 years ago

Both locations in the screenshot are using the same GPS coordinates and OpenWeatherMap API. MMM-DarkSkyForecast is using gerjomarty's fork and the data is near identical to The Weather Channel iOS app.

Time

    {
        module: "MMM-OpenWeatherForecast",  
        position: "top_left",
        config: {
            apikey: "******",
            latitude: "41.8781136",
            longitude: "-87.6297982",
            updateInterval: 10,
            updateFadeSpeed: 2000,
            units: "imperial",        
            concise: false,
            useAnimatedIcons: true,
            animateMainIconOnly: true,
            forecastLayout: "table", 
            iconset: "4c", 
            showForecastTableColumnHeaderIcons: true,
            showFeelsLikeTemp: true,
            forecastHeaderText: "Weather Forecast",
            label_maximum: "",
            label_high: "",
            label_low: "",
            label_ordinals: ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
            showExtraCurrentConditions: true,
            extraCurrentConditions: {
              highLowTemp: true,
              precipitation: true,
              sunrise: true,
              sunset: true,
              wind: true,
              barometricPressure: false,
              humidity: false,
              dewPoint: false,
              uvIndex: false,
              visibility: false
            },
            showHourlyForecast: true,
            hourlyForecastTableHeaderText: "",
            hourlyExtras: {
              precipitation: true,
              wind: true,
              barometricPressure: false,
              humidity: false,
              dewPoint: false,
              uvIndex: false,
              visibility: false
            },
            maxDailiesToShow: 3,
            showDailyTableHeaderRow: false,
            dailyExtras: {
              precipitation: true,
              sunrise: false,
              sunset: false,
              wind: true,
              barometricPressure: false,
              humidity: false,
              dewPoint: false,
              uvIndex: false
            },
        }
    },{
        module: "MMM-DarkSkyForecast", 
        position: "top_right",
        config: {
            apikey: "******",
            latitude: "41.8781136",
            longitude: "-87.6297982",
            updateInterval: 10,
            units: "imperial",
            showHourlyForecast: true,
            maxDailiesToShow: 4,
            concise: true,
            animateMainIconOnly: true,
            forecastLayout: "table", //tiled
            iconset: "4c",  //3c 5c
            showForecastTableColumnHeaderIcons: true,
        }
    },
jclarke0000 commented 3 years ago

For the time issue, It appears that I've misinterpreted OpenWeather's API documentation. The docs state that the time is returned in UTC. Also provided is a timezone offset. So interpreted this to mean that in order to get local time I needed to add the offset to the UTC time to get local time, and had done that in my code.

At first your config worked fine for me, so I couldn't figure out what was going on... it turns out that OpenWeather returns time local to where the request was made (e.g. timezone translation has already been done. So if I look up Chicago from London, the hourly times I see will be in MY local time, not Chicago's. Similarly if I change my computer's timezone to Chicago's the hourlies are translated correctly.

I will remove the the part of my code that explicitly adds the offset to hourly times.

As for the temperature showing incorrectly, you have showFeelsLikeTemp set to true in the config. This will replace the actual temperature with the "Feels like" temperature anywhere you see temperature (except Hi/Lo... that is always actual). If you set this config to false do you then see correct temperatures? Also keep in mind that OpenWeather uses the weather station closest to the long/lat you provide. It's normal to see a difference of a degree or two if you slightly change you long/lat so that another weather station is used as the source.

jclarke0000 commented 3 years ago

Code has been updated to remove the explicit timezone offset calculation. Hourly forecast time display should now be fixed. @nitewing76 Can you also try changing the config to showFeelsLikeTemp : false and tell me if you're seeing more consistent temperatures?