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
208 stars 111 forks source link

Missing forecast icons from pages (except home page) #947

Closed WiggyToo closed 2 months ago

WiggyToo commented 3 months ago

Please don't delete these questions! They are asked almost with every issue - answering them as below saves us time from asking them!

First step Try to debug the skin yourself. If you can't figure it out, please include the debug information (text, screenshots, etc.). See this guide on debugging the skin. https://github.com/poblabs/weewx-belchertown#how-to-use-debug

Describe the bug A clear and concise description of what the bug is. The forecast icon displays correctly on this page https://www.wiggytoo.co.uk/ e.g. https://www.wiggytoo.co.uk/images/fog.png but does not display on any of the other pages

https://www.wiggytoo.co.uk/graphs/ https://www.wiggytoo.co.uk/records/ https://www.wiggytoo.co.uk/reports/ https://www.wiggytoo.co.uk/about/

Which all display the https://www.wiggytoo.co.uk/images/unknown.png

Link to your website (IMPORTANT) See above

Version of the skin you're using 1.3.1

To Reproduce Steps to reproduce the behavior: Click this link and see icon not displaying correctly https://www.wiggytoo.co.uk/about/

Expected behavior A clear and concise description of what you expected to happen. I would expect the same icon that is shown on the home page to display on the other pages

Screenshots If applicable, add screenshots to help explain your problem.

Device Information (please complete the following information):

Additional context Add any other context about the problem here. Maybe a potential fix? I have seen this reported and fixed in other bug reports, mainly by deleting forecast.json which is then regenerated, and I have fixed this problem the same way and it works for a while (one cycle?) but then fails again.

The log shows this error user.belchertown: aeris-icon-list.json is missing in /etc/weewx/skins/Belchertown/images/aeris-icon-list.json although the file is there and I suspect it is this code that is generating the error in belchertown.py line 1165

def aeris_icon(data):

https://www.aerisweather.com/support/docs/api/reference/icon-list/

            iconlist_file_path = os.path.join(
                self.generator.config_dict["WEEWX_ROOT"],
                self.generator.skin_dict["SKIN_ROOT"],
                self.generator.skin_dict.get("skin", ""),
                "images/aeris-icon-list.json",
            )
            if os.path.exists(iconlist_file_path):
                icon_name = data.split(".")[0]  # Remove .png
                with open(iconlist_file_path, "r") as dict:
                    icon_dict = json.load(dict)
                return icon_dict[icon_name]
            else:
                logerr("aeris-icon-list.json is missing in " + iconlist_file_path)
                return 'unknown'

For some reason it can't get the right icon and returns unknown and the missing icon list error - although the file is there.

At one point I suspected a permissions issue, but that seems OK now.

Whilst it is only cosmetic I'd love to know why it is failing and what I could do to fix it.

HELP WANTED If you have a fix for this, please submit a pull request against the development branch!

WiggyToo commented 3 months ago

See https://github.com/poblabs/weewx-belchertown/issues/432 and https://github.com/poblabs/weewx-belchertown/issues/692

poblabs commented 3 months ago

This is strange, and I'm not sure off top of my head what it is. I've grabbed a copy of your forecast.json so I can see if I can take a look. If you delete the forecast.json again, and let it rebuild, will it fix it again?

WiggyToo commented 3 months ago

I'll try that now.

  1. Stop Weewx
  2. Delete Forecast.json
  3. Start Weewx
  4. Wait

Previously I was running the reports manually to save waiting but this was as root so I wondered if running it as another user created a permission issue.

Will let you know when it has recreated the forecast.

WiggyToo commented 3 months ago

On its own that doesn't fix it, the icon list not found error repeats about 9 times in the log.

Gav

poblabs commented 3 months ago

I'm heading out on holiday shortly, I'll see if I can take a look at whats going on unless someone else knows sooner than me!

WiggyToo commented 3 months ago

It can sure wait until after holidays! Have a good one.

Gav

WiggyToo commented 3 months ago

I have not managed to fix this reliably, it is working right now after tinkering with belchertown.py and then going back to the released version of this file.

What I have noticed is that sometimes the broken icon shows briefly then the correct one on the home page as if it is some sort of timing issue.

I am not sure why an error is generated when the /etc/weewx/skins/Belchertown/images/aeris-icon-list.json file is definitely there.

I suspected permissions for a while, I don't know enough to debug it really - I have tried a few things but nothing is a reliable fix, I also don't know how the py file interacts with the other files to product the js file that is part of the website.

While writing this another report cycle has happened an the icon is back to unknown.png - on the home page when you refresh you get a brief glimpse of unknown.png before the right one loads e.g. https://www.wiggytoo.co.uk/images/drizzle.png, on the other pages this refresh does not happen and you are just left with https://www.wiggytoo.co.uk/images/unknown.png.

Regards, Gav

Here is the broken icon on mobile on home page.

Screenshot_2024-07-05-17-21-08-69_40deb401b9ffe8e1df2f1cc5ba480b12.jpg

WiggyToo commented 3 months ago

I have copied over a new aeris-icon-list.json and it now seems to be working - for some reason it seems to be able to get into a broken state and I'm 90% sure it is an issue with the check for the file existence, either permissions or something that means it fails to find the file and returns "unknown" - I am using WINSCP to look at and manage files so there may be a chance that accessing it this way is causing a file permission issue. I'll leave it to run for a day and see what happens, either way as it can be made to work it is not a code issue. Or it is an issue with the current observation icon, so works with some icons and not others or when the icon state changes for example.

WiggyToo commented 2 months ago

I've tracked this down to permissions on the images folder in the Belchertown skin folder, for some reason on my setup it was set to 644 rather than 755 (from memory). Whether this was a hangover from the upgrade or not I don't know. I followed the fixes shown here (https://github.com/weewx/weewx/wiki/Understanding-permissions#how-to-fix-file-permissions) but that didn't fix it, in the end I manually set the permissions on that folder via WinSCP.

The intermittent nature of the problem was that it worked when I ran reports via the Putty as root, but when run by the weewx service it failed.

As a footnote the broken image icon on my mobile went away when I cleared the cache.

Issue closed.