NWS forecast block images not working

Post Reply
User avatar
Andy Thompson
Newbie
Newbie
Posts: 1
Joined: Sat Aug 26, 2017 4:40 pm
Location: Hanska, MN
Station model: X2 Davis Vantage Pro2 +
Software: WeeWX
Contact:

NWS forecast block images not working

Post by Andy Thompson » Sat May 04, 2024 12:50 pm

The forecasts are still working but the images are not. I know they have changed how things work several times throughout the years. Is anyone else seeing this issue?
Regards,
Andy Thompson
www.somnwx.com

Image

User avatar
w7las
Newbie
Newbie
Posts: 7
Joined: Mon Mar 12, 2018 9:50 pm
Location: Pahrump, NV
Station model: Davis Vantage Vue
Software: Weather Display

Re: NWS forecast block images not working

Post by w7las » Sat May 04, 2024 9:05 pm

I'm having the same problem. The data is present but there is a question make in the place of the image or icon. I too am searching for a solution.

milesb
Observer
Observer
Posts: 49
Joined: Tue Mar 26, 2019 10:38 pm
Location: Asheville, NC
Station model: Davis Vantage Pro2
Software: Weather Display
Contact:

Re: NWS forecast block images not working

Post by milesb » Sun May 05, 2024 4:30 am

Same here, sounds like a change on the NWS side.

Bigbaywx
Observer
Observer
Posts: 24
Joined: Mon Jun 22, 2020 8:47 pm
Station model: Davis Vantate Pro2
Software: weatherlink data logger

Re: NWS forecast block images not working

Post by Bigbaywx » Sun May 05, 2024 12:58 pm

Been like that for about a week I noticed.

rogers
Observer
Observer
Posts: 12
Joined: Sun Aug 20, 2017 8:10 pm
Location: Lindale, GA USA
Contact:

Re: NWS forecast block images not working

Post by rogers » Sun May 05, 2024 1:07 pm

Same here...looks like NWS changed something on the local 5/7 day forecasts.

Wish I knew enough programming to fix it without completely hosing it.

Same as the NWS weather alerts block not working.

mchd17
Forecaster
Forecaster
Posts: 196
Joined: Sat Mar 17, 2018 2:01 am
Location: Illinois
Station model: Davis Pro2 Plus
Software: Meteobridge

Re: NWS forecast block images not working

Post by mchd17 » Sun May 05, 2024 11:21 pm

Same issue
Image

gjstenbe
Observer
Observer
Posts: 14
Joined: Sun Jan 07, 2018 8:51 pm
Location: Yukon, OK, USA
Station model: Davis Vantage Pro 2
Software: Weather Display
Contact:

Re: NWS forecast block images not working

Post by gjstenbe » Mon May 06, 2024 9:31 pm

Same for me in both the nwsForecast and nwsForecastCustom blocks.

I was hoping it was going to be something as simple as changing http:// to https:// on line 179 of the nwsForecastBlock.php file. Unfortunately, that didn't work.

Upon inspection of the cache file, I see where it puts in the filename it wants. For instance, "img class="forecast-icon" src="newimages/medium/scttsra40.png" However, when I copy and paste the link to the file from the block rendered on my web page, all it links to is https://forecast.weather.gov/. It isn't putting the filename it wants after the first part of the link. Interestingly enough, when I manually string together https://forecast.weather.gov/newimages/ ... tsra40.png and go to it, the image pops right up.

So not sure what's happening in the rendering of the block and the image source links. Seems as though the image files are still there and accessible, but that something isn't working in the block all of a sudden. I'm sure some of the more adept PHP gurus here might be able to spot what's happening.

Bigbaywx
Observer
Observer
Posts: 24
Joined: Mon Jun 22, 2020 8:47 pm
Station model: Davis Vantate Pro2
Software: weatherlink data logger

Re: NWS forecast block images not working

Post by Bigbaywx » Tue May 07, 2024 6:28 pm

This is probably the offending string in line 179.


<img src="http://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">

enephler
Observer
Observer
Posts: 17
Joined: Mon Sep 04, 2017 9:49 pm
Location: L'Anse, MI USA
Station model: Davis Pro2
Software: Meteobridge
Contact:

Re: NWS forecast block images not working

Post by enephler » Wed May 08, 2024 8:49 pm

The images aren't showing for me either.
I think someone needs to take over this mereotemplate project, nothing is getting fixed.

User avatar
MonyMony
Forecaster
Forecaster
Posts: 189
Joined: Sun Aug 20, 2017 12:54 pm
Location: Elkton, Maryland, US
Station model: Davis Pro 2
Software: WeatherCat/Meteobridge
Contact:

Re: NWS forecast block images not working

Post by MonyMony » Tue May 14, 2024 2:22 pm

NWS added a new Class label called 'forecast-icon' that the Meteotemplate blockcode was not handling. If you make the following change it should work:

On/about line 88 of nwsForecastBlock.php change

Code: Select all

preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
to

Code: Select all

preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
At least for me this did the trick. I hope it works for others too.
Last edited by MonyMony on Wed May 15, 2024 12:50 am, edited 1 time in total.
Image

gjstenbe
Observer
Observer
Posts: 14
Joined: Sun Jan 07, 2018 8:51 pm
Location: Yukon, OK, USA
Station model: Davis Vantage Pro 2
Software: Weather Display
Contact:

Re: NWS forecast block images not working

Post by gjstenbe » Tue May 14, 2024 3:29 pm

MonyMony:

Your code change is the ticket and fixed mine right up! Many thanks for that! I also recommend changing line 180 or thereabouts from http:// to https://

Code: Select all

<img src="https://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">

Also, for anyone that is using the nwsForecastCustom block, MonyMony's code change works as a fix for that block, too (at least it fixed mine). Edit the customLoader.php file that goes with that block, and make the change on or about line 28. I also recommend changing the http:// to https:// on or about line 120 of that file to read:

Code: Select all

<img src="https://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastCustomIconImg">
Thanks again everyone!

rogers
Observer
Observer
Posts: 12
Joined: Sun Aug 20, 2017 8:10 pm
Location: Lindale, GA USA
Contact:

Re: NWS forecast block images not working

Post by rogers » Tue May 14, 2024 3:32 pm

Excellent!

Appreciate it!

That worked for me, and is was on line 88. All working great. Any ideas on how to fix the NWS Alerts/Warnings?

BTW,

Jachym indicates he is going to work on fixing many of the blocks over the summer holidays when he has time.

Thanks,

Steve

User avatar
MonyMony
Forecaster
Forecaster
Posts: 189
Joined: Sun Aug 20, 2017 12:54 pm
Location: Elkton, Maryland, US
Station model: Davis Pro 2
Software: WeatherCat/Meteobridge
Contact:

Re: NWS forecast block images not working

Post by MonyMony » Tue May 14, 2024 7:18 pm

I posted this into the discussion about the NWS alerts:
MonyMony wrote: Tue May 14, 2024 9:26 pm Hello All,

Back in 2021, I posted how I created a custom block to utilize the NWS Alert script developed by Saratoga-weather.org. I have updated my provided zip file that can be used to create a block on your page. Just make sure update the variables listed below to match your website and regional settings. I hope this will help!

DOWNLOAD - https://www.cecilweather.com/weather/ce ... s_v1.2.zip
MonyMony wrote: Sat Jan 02, 2021 1:45 am
I did take the code you posted for the Saratoga National Weather Service Alerts and made some modification to better integrate it into Meteotemplate. The updated block can be downloaded by going to https://www.cecilweather.com/weather/ce ... s_v1.2.zip and installed just like any other Meteotemplete block.

To make this work, the nws-alerts-config.php file needs to be directly edited. I did the following updates in this file to make this work well within Meteotemplate:
  • $myZC - with the wanted zones by getting codes from alerts.weather.gov
  • $ourTZ - with the current time zone
  • $cacheFileDir - directory with the alerts cache is stored.
  • $icons_folder - directory for the icons are stored
  • $blockpath - this is something customized for Meteotemplete. This is the path where this block resides on your website.
  • $alertURL - path to where the nws-details.php file is located
  • $summaryURL - path to where the nws-summary.php file is located
The rest of the variables should also be checked and adjusted as needed. Particularly if you are going to retrieve more than a couple zones then you should set the $noCron to FALSE and setup a CRON job. If anyone is reading this wondering how all this works, please check out the README file included in the zip as it contains all of the details from Saratoga-weather.org who get all of the credit for developing this script. I also left my settings in the nws-alerts-config.php file to be used as a guide. Hope this helps!

You can view the updates in action by going to my site - https://www.cecilweather.com. I would say PM me if you have questions but I might not be able to reply back privately.
Image

mchd17
Forecaster
Forecaster
Posts: 196
Joined: Sat Mar 17, 2018 2:01 am
Location: Illinois
Station model: Davis Pro2 Plus
Software: Meteobridge

Re: NWS forecast block images not working

Post by mchd17 » Tue May 14, 2024 10:10 pm

Line 88 worked good, thank you!
Image

enephler
Observer
Observer
Posts: 17
Joined: Mon Sep 04, 2017 9:49 pm
Location: L'Anse, MI USA
Station model: Davis Pro2
Software: Meteobridge
Contact:

Re: NWS forecast block images not working

Post by enephler » Wed May 15, 2024 12:06 pm

Wonderful! Works great. Thank you!
MonyMony wrote: Tue May 14, 2024 2:22 pm NWS added a new Class label called 'forecast-icon' that the Meteotemplate blockcode was not handling. If you make the following change it should work:

On/about line 88 of nwsForecastBlock.php change

Code: Select all

preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
to

Code: Select all

preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
At least for me this did the trick. I hope it works for others too.

danb35
Observer
Observer
Posts: 20
Joined: Sat Jan 20, 2018 4:14 pm
Station model: Davis Pro 2
Software: WeeWX

Re: NWS forecast block images not working

Post by danb35 » Tue Oct 14, 2025 10:03 pm

In my perhaps-not-so-humble opinion, the fundamental problem is that the existing block is just scraping HTML to gather its data, rather than using NWS' API for the purpose. I've updated this block (and the warnings block) to use that API:
https://www.meteotemplate.com/forum/vie ... php?t=2628

...as well as some fixes to the radarUS block. I'll probably do the multiple forecast and custom forecast blocks in due course, but no particular ETA on those.

Post Reply