poblabs / weewx-belchertown

A clean and modern weewx skin with real time streaming updates, forecast data and interactive charts. View it in action at BelchertownWeather.com
https://belchertownweather.com
GNU General Public License v3.0
206 stars 111 forks source link

Aeris Forecast Not Shown #512

Closed gary-hammer closed 3 years ago

gary-hammer commented 3 years ago

Describe the bug Using master.zip downloaded today (3 Jan 20) the Aeris forecast fails to load.

Link to your website (IMPORTANT) https://weather.ghammer.net

Version of the skin you're using 1.2 (master as of 3 Jan 2020)

To Reproduce Steps to reproduce the behavior:

  1. Load website
  2. See error

Expected behavior Aeris forecast should be populated.

Screenshots N/A

Device Information (please complete the following information):

Additional context None weather.ghammer.net-1609710621236.log bt_conf.txt

uajqq commented 3 years ago

This happened to me too at first. Delete public_html/json/forecast.json, restart weewx, and either wait for another update interval or force with wee_reports.

gary-hammer commented 3 years ago

Thanks for the idea, but it had no effect. This is what I'm referring to.

aeris

gary-hammer commented 3 years ago

This seems to be the error according to my console output: Uncaught ReferenceError: precip is not defined

Looking at the source in the console: forecast_row.push( { "weekday": weekday, "image_url": image_url, "condition_text": condition_text, "avgTemp": avgTemp, "minTemp": minTemp, "maxTemp": maxTemp, "windSpeed": windSpeed, "windGust": windGust, "snow_depth": snow_depth, "snow_unit": snow_unit, "precip": precip, "forecast_link": forecast_link

gary-hammer commented 3 years ago

Additionally, the transmitter battery is shown as low in the about page. According to the loop packets and Davis weatherlink.com, it is good. ID 1 Woodmar Glen Last updated: January 3, 2021 / 9:15 PM Signal Strength Davis Talk Rssi -69 Reception 100% Power Transmitter Battery Flag Good ID 2 Woodmar Glen Wind Last updated: January 3, 2021 / 9:15 PM Signal Strength Davis Talk Rssi -52 Reception 100% Power Transmitter Battery Flag Good

michaelundwd commented 3 years ago

@gary-hammer Just checked your website at 5.33 am this morning your time , and forecasts are showing correctly. Michael Screenshot 2021-01-04 103502

michaelundwd commented 3 years ago

I seem to recall having this problem when I was developing the 1hr and 3hr forecasts. Weewx would sometimes take two archive cycles to generate the forecasts correctly and I could never find why. It's something to do with checking whether the forecast is stale or not, but it does resolve as @uajqq reported. @ChrisM510 reported a similar issue after a Pi upgrade in #455 that I assume has also resolved itself. I have left this note here in case other people have the problem.
Michael

michaelundwd commented 3 years ago

I have looked into the code that generates "precip". If there are any snow values "precip" is not set and hence would generate undefined. It's line 1283 in belchertown.js.tmpl in the latest master. The code I submitted does have a "precip= 0 if there is any snow to catch this. This did not make it to the merge it seems. However, why would the first forecast return a non-zero snow value? I think the key is in the following line from Gary's log. DevTools failed to load SourceMap: Could not load content for chrome-extension://aoiidodopnnhiflaflbfeblnojefhigh/purify.min.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME

Comparing that with his operational site, it indicates that no forecast data was loaded, so the first forecast file does not contain any data. The test for any data in the forecast is at line 1226. Can any js experts throw any light on this please?

Michael

ChrisM510 commented 3 years ago

I seem to recall having this problem when I was developing the 1hr and 3hr forecasts. Weewx would sometimes take two archive cycles to generate the forecasts correctly and I could never find why. It's something to do with checking whether the forecast is stale or not, but it does resolve as @uajqq reported. @ChrisM510 reported a similar issue after a Pi upgrade in #455 that I assume has also resolved itself. I have left this note here in case other people have the problem. Michael

Correct - I found I ran into this again (and more often) when I would have to manually update my database (usually to remove phantom lightning strikes). The procedure I found that now works every time is 1) shut down WeeWX, 2) update database, 3) delete '/var/www/html/json/forecast.json', 4) start WeeWX. Note that I stopped having weird issues when I did NOT run 'sudo wee_reports', but rather let the forecast update on its own. When I used to run wee_reports, the forecast.json file would usually NOT update. Took some trial & error to figure this one out. :-)

gary-hammer commented 3 years ago

While gathering logs and info for this ticket, I pulled the forecast.json file and it was populated. Had the proper METAR, etc. I did use wee_reports but it did create the forecast file after I had removed it, as I didn't check each one, I have to assume they were populated. If the precip error is corrected I'm happy to test it out next snowfall. All that should be required is to remove the existing forecast.json and wait for reports to run. From Pat's comments on his blog, it looked like turning off the METAR solved his problem. I think I tried that, but as I'm unsure, will try that if there is a next time. The resolution in #455 was simply time it seems. Meantime, it would be helpful if the install notes mentioned the need for patience regarding the forecast.

In any event, the new forecast is excellent, I love the smooth, immediate change from time period to time period. I won't close this in case it's needed as a reminder, but feel free to do so if you wish.

michaelundwd commented 3 years ago

@ChrisM510 Thanks for the update. That was pretty much how I managed to overcome it I think. It was better to stop weewx rather than just restart it I found. @gary-hammer Thanks for the update and glad you like the forecasts. I suggest leaving the code as it is until it snows and we get proof that really is the problem. Then if you were to make the change where I have indicated to see if that fixes it. There is still a mystery about the first load after deleting. I will see how Pat wants the install notes updated. @poblabs Where do you want any changes re the forecasts recorded as suggested by @gary-hammer? Do you have any comments re the precip code (I see it was not in what I submitted) and what happens on a weewx restart after deleting forecast.json? Michael

gary-hammer commented 3 years ago

Thanks for the update and glad you like the forecasts. I suggest leaving the code as it is until it snows and we get proof that really is the problem.

I shall do just that.

Just to be clear, if I made a change in the skin settings inside weewx.conf I'd do a restart then wee_reports after weewx was up for a minute. I did not stop then start weewx. I don't see a difference in the logs with debug on for either method.

ArendPWS commented 3 years ago

@michaelundwd Noticed the forecast problem this morning, it is snow related. Added this line as a quick fix:

precip = data[(forecast_interval)][0]["response"][0]["periods"][i]["pop"];

            if ( ( data[(forecast_interval)][0]["response"][0]["periods"][i]["snowCM"] > 0 ) || ( data[(forecast_interval)][0]["response"][0]["periods"][i]["snowIN"] > 0 ) ) {
                // Determine snow unit
                if ( ( "$Extras.forecast_units" == "si" ) || ( "$Extras.forecast_units" == "ca" ) || ( "$Extras.forecast_units" == "uk2" ) ) {
                    var snow_depth = data[(forecast_interval)][0]["response"][0]["periods"][i]["snowCM"];
                    var snow_unit = "cm";
                } else {
                    var snow_depth = data[(forecast_interval)][0]["response"][0]["periods"][i]["snowIN"];
                    var snow_unit = "in";
                }
                // Added extra precip to prevent forecast error
                precip = data[(forecast_interval)][0]["response"][0]["periods"][i]["pop"];
            } else if ( data[(forecast_interval)][0]["response"][0]["periods"][i]["pop"] > 0 ) {
                // Rain percent of precip
                precip = data[(forecast_interval)][0]["response"][0]["periods"][i]["pop"];
            } else {
                precip = 0;
                snow_depth = 0;
                var snow_unit = "";
            }

Also uncommented this line in the "if ( forecast_interval == "forecast_1hr" )":

 output_html += '<img src="'+get_relative_url()+'/images/snowflake-icon-15px.png"> <span>'+ parseFloat( forecast_row[i]["snow_depth"] ).toFixed(0) +'<span> ' + forecast_row[i]["snow_unit"];

and commented out the line above that one:

 // output_html += '<img src="'+get_relative_url()+'/images/snowflake-icon-15px.png"> <span>';

This is the result:

Forecast_error_snow_fix_example

poblabs commented 3 years ago

Could this be related to #471?

ArendPWS commented 3 years ago

Could this be related to #471?

Originally posted by @poblabs in https://github.com/poblabs/weewx-belchertown/issues/512#issuecomment-754627679

You are still using your original forecast code? I have been using Michaels additions for a while now and besides the issue mentioned above haven't noticed anything ordinary. Below is a screenshot for the 7 days forecast and the decrease in snowdepth looks natural to me. But snowfall has become rare in my country, so I won't have many opportunities to check if everything involving snowfall is handled correctly. Not sure if your issue has been fixed in Michaels additions.

24 uurs 7 dagen verwachting sneeuw

poblabs commented 3 years ago

Oops I'm guilty! I haven't had time to update to master yet! I'll do that 😄

Distortionist commented 3 years ago

My forecast vanishes too, I have updated recently but I have no idea if anything was added to fix this so I just updated belchertown, and I will report if the problem persists. It just randomly disappears and stops showing for a random interval of time and suddenly works again. I have no clue why lol. I will update in a couple of days if it is fixed or not.

michaelundwd commented 3 years ago

This should have been fixed in #519 that has been merged into the master, so you should be ok. If you do get the missing forecast again, could you look at the error log and see if you are getting the "precip not defined error". That is the one I fixed in #519, so if its not that I would like to know please. Thanks Michael

gary-hammer commented 3 years ago

Im happy to report that with the old (when reported) version of the skin, today I had no forecast as it is snowing. I downloaded master, installed, and have forecasts again.

I'm going to close this ticket. Feel to re-open it if you want to track it a bit more.

michaelundwd commented 3 years ago

@gary-hammer Thanks for letting me know - I agree with the closure. Michael