NWS Forecast and minus temperatures
- dmgould
- Forecaster

- Posts: 173
- Joined: Sat Aug 26, 2017 2:43 am
- Location: Divide, Colorado, USA
- Station model: Davis Pro 2 Plus Wireless
- Software: Meteobridge
- Contact:
NWS Forecast and minus temperatures
Attached images show the NWS Forecast block on my page and the same data on the NWS official page. I couldn't figure out what was going on with the temperature numbers missing and in the wrong place in the block. It looks like there is an issue with displaying negative temperature values in the block version. The negative temperatures don't show and they cause the rest of the numbers to appear off by one space.
Dave G

- dmgould
- Forecaster

- Posts: 173
- Joined: Sat Aug 26, 2017 2:43 am
- Location: Divide, Colorado, USA
- Station model: Davis Pro 2 Plus Wireless
- Software: Meteobridge
- Contact:
Re: NWS Forecast and minus temperatures
Checking my cache file nwsForcastChace.txt, <p class="temp temp-low">Low: -2 °F is in the correct place with the correct value. It looks like code for that block sets up an array with a counter to line up the images and temperatures to display in the block. When it encounters a negative temperature something happens, maybe to the counter??, and it skips any negative temperatures. Also, this same thing happens in the nwsForecastCustom block. Whatever is happening occurs in both blocks with temperatures below zero.
Dave G

- Jachym
- Site Admin

- Posts: 1686
- Joined: Fri Aug 18, 2017 10:12 pm
- Location: Brno, Czech Republic
- Station model: WH1080
- Software: Meteobridge
- Contact:
Re: NWS Forecast and minus temperatures
Could be some minor change in their code, since the code uses HTML scraping this would affect it. I will have a look
- dmgould
- Forecaster

- Posts: 173
- Joined: Sat Aug 26, 2017 2:43 am
- Location: Divide, Colorado, USA
- Station model: Davis Pro 2 Plus Wireless
- Software: Meteobridge
- Contact:
Re: NWS Forecast and minus temperatures
Thanks for looking at this. I also noticed the link to that scraped code is still http. It forwards to https. If you end up making a change to the block you might want to change that link as well. I figured out it's setting up a table for each entry, but I get lost following the array.
Dave G

- dmgould
- Forecaster

- Posts: 173
- Joined: Sat Aug 26, 2017 2:43 am
- Location: Divide, Colorado, USA
- Station model: Davis Pro 2 Plus Wireless
- Software: Meteobridge
- Contact:
Re: NWS Forecast and minus temperatures
I made the follow minor change to line 90 in nwsForecastBlock.php. It seems to have fixed the issue of skipping past a negative (below zero) temperature. It now shows the minus sign and places the temperatures into the correct places. I'll keep track of it for a bit to see if the fix holds. If so, I'll make the same change in customLoader.php in the nwsForecastCustom Block which currently has the same issue with minus temperatures. I also updated the data source for the NWS images to https as that link was forwarding there.
Here are snips of the modified code and the block after the change.
Here are snips of the modified code and the block after the change.
Dave G

- MonyMony
- Forecaster

- Posts: 192
- Joined: Sun Aug 20, 2017 12:54 pm
- Location: Elkton, Maryland, US
- Station model: Davis Pro 2
- Software: WeatherCat/Meteobridge
- Contact:
Re: NWS Forecast and minus temperatures
Thanks everyone for the post as I was noticing the same issue.