It is currently June 28th, 2024, 6:34 pm

Weather Skins Not Working

Get help with creating, editing & fixing problems with skins
User avatar
SilverAzide
Rainmeter Sage
Posts: 2676
Joined: March 23rd, 2015, 5:26 pm

Re: Weather Skins Not Working

Post by SilverAzide »

Thinkr8 wrote: June 24th, 2024, 10:41 pm I'm not getting any results, no matter which city in the world I enter. TY :)
Open a PowerShell prompt and enter the following command, changing the XXXX to the name of a city/state/country. Post the results here.

Code: Select all

(curl -Uri 'https://nominatim.openstreetmap.org/search?q=XXXX&format=json&addressdetails=0' -Method Get).RawContent
I'm getting somewhat random results. Searching popular places gives me a single result, narrowing down the query or selecting a small town can get me additional results.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weather Skins Not Working

Post by jsmorley »

SilverAzide wrote: June 24th, 2024, 11:23 pm Open a PowerShell prompt and enter the following command, changing the XXXX to the name of a city/state/country. Post the results here.

Code: Select all

(curl -Uri 'https://nominatim.openstreetmap.org/search?q=XXXX&format=json&addressdetails=0' -Method Get).RawContent
I'm getting somewhat random results. Searching popular places gives me a single result, narrowing down the query or selecting a small town can get me additional results.

Code: Select all

[{"place_id":4644690,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":206826,"lat":"38.7332684","lon":"-77.05596","class":"place","type":"locality","place_rank":25,"importance":0.35703732828216783,"addresstype":"village","name":"Fort Hunt","display_name":"Fort Hunt, Fairfax County, Virginia, United States","boundingbox":["38.7098000","38.7688102","-77.0819850","-77.0413640"]}]
User avatar
balala
Rainmeter Sage
Posts: 16358
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skins Not Working

Post by balala »

SilverAzide wrote: June 24th, 2024, 10:15 pm Looks to me like they are now limiting the API query to a single result. Unfortunate.
No, don't think. At least I get right now the same number of results as previously and this is greater than one.
User avatar
sl23
Posts: 1226
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Weather Skins Not Working

Post by sl23 »

Sorry, I couldn't recall where I asked about this, search didn't help me either.

My weather skin has stopped working again, giving four errors:

Code: Select all

Something went wrong. (RM\Weather\Weather.ini)
RegExp matching error (-1) (RM\Weather\Weather.ini - [mWeatherParent])
No results found for that location. (RM\Weather\Weather.ini)
RegExp matching error (-1) (RM\Weather\Weather.ini - [mWeatherLocationParent])
Is this due to the API key changing again? I did try finding it from the page source on weather.com, but it was the same API key I already have. I only have location and current temperature in this skin.

I reduced this from Jelle Dekkers weather skin, JDWS-04:
Skin code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,1
OnRefreshAction=[!UpdateMeter *] [!UpdateMeter *] [!Redraw]
@Include=WeatherParser.inc

[Metadata]
Name=Weather
Author=sl23
Version=2023-09-18
License=Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Information=Adapted from JDWS-04 by Jelle Dekkers (github.com/adriaanjelle)

[Variables]
Green=128,255,0
White=255,255,255,200

WeatherLocation=***** UK
; Just enter your city's name or your address here or whatever. Anything should work here.
; TIP: Check Rainmeter's About/log to see what location it got.

========================================
; STYLES
========================================
[Style]
FontFace=Trebuchet MS
FontColor=#White#
FontSize=12
AntiAlias=1
DynamicVariables=1
UpdateDivider=-1

[sHighlight]
MouseOverAction=[!SetOption #CURRENTSECTION# FontColor "#Green#"] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# FontColor ""] [!UpdateMeter #CURRENTSECTION#] [!Redraw]

========================================
; WEATHER
========================================
[WeatherCurrentTemperature]
Meter=String
MeterStyle=Style | sHighlight
Text=[mWeatherCurrentTemperature]°
LeftMouseUpAction=[!Refresh]
MiddleMouseUpAction=[!EditSkin]
ToolTipIcon=Info
ToolTipTitle=[mWeatherLocationCity]
ToolTipText=L - Refresh#CRLF#M - Edit
X=2
Y=0

WebParser code:

Code: Select all

[Variables]
Language=en-GB
WeatherAPIKey=****2ea9dd2f4*****2ea9dd2f77****
WeatherUnitsMetric=m
WeatherUnitsImperial=e
WeatherRegExpString=((?(?=null)null|".*"))
WeatherRegExpNumber=((?(?=null)null|.*))
WeatherSubstitute="^null$":"", '^"(.*)"$':"\1", "^\\1$":""
WeatherUnits=Metric

[mInternetConnectivity]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
OnChangeAction=[!CommandMeasure mWeatherLocationParent Update]

; ================================================

[mWeatherLocationParent]
Measure=WebParser
URL=https://nominatim.openstreetmap.org/search?q=#WeatherLocation#&format=geocodejson&limit=1&addressdetails=1
RegExp=(?siU)"features":\[{"type":"Feature","properties":{"geocoding":{.*,"label":"(.*)",.*,"admin":{"level\d+":"(.*)".*}}},"geometry":{"type": "Point","coordinates": \[(.*), (.*)\]}}\]
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
UpdateRate=(60*15)

FinishAction=[!UpdateMeasureGroup WeatherLocation] [!EnableMeasure mWeatherParent] [!UpdateMeasure mWeatherParent] [!Log "Location found: [mWeatherLocation]" Notice]
OnConnectErrorAction=[!UpdateMeasureGroup WeatherLocation] [!EnableMeasure mWeatherParent] [!UpdateMeasure mWeatherParent] [!Log "Unable to connect to Nominatim." Error]
OnRegExpErrorAction=[!UpdateMeasureGroup WeatherLocation] [!EnableMeasure mWeatherParent] [!UpdateMeasure mWeatherParent] [!Log "No results found for that location." Error]

; ================================================

[mWeatherLocation]
Group=WeatherLocation
Measure=WebParser
URL=[mWeatherLocationParent]
StringIndex=1

[mWeatherLocationCity]
Group=WeatherLocation
Measure=WebParser
URL=[mWeatherLocationParent]
StringIndex=2
Substitute="":"Earth"

[mWeatherLocationLat]
Group=WeatherLocation
Measure=WebParser
URL=[mWeatherLocationParent]
StringIndex=4
Substitute="":"None"

[mWeatherLocationLon]
Group=WeatherLocation
Measure=WebParser
URL=[mWeatherLocationParent]
StringIndex=3
Substitute="":"None"

; ================================================

[mWeatherParent]
Group=Parent
Measure=WebParser

URL=https://api.weather.com/v3/aggcommon/v3-wx-observations-current;v3-wx-forecast-daily-15day?format=json&geocode=[&mWeatherLocationLat],[&mWeatherLocationLon]&units=[#WeatherUnits[#WeatherUnits]]&language=[#Language]&apiKey=#WeatherAPIKey#
RegExp=(?siU)"v3-wx-observations-current":.*{(.*)}.*"v3-wx-forecast-daily-15day":.*{(.*),"daypart":\[{(.*)}\]}
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
UpdateRate=1

FinishAction=[!EnableMeasureGroup Weather] [!UpdateMeasureGroup Weather] [!UpdateMeter *] [!UpdateMeter *] [!Redraw] [!Log "Finished parsing weather data." Notice]
OnConnectErrorAction=[!EnableMeasureGroup Weather] [!UpdateMeasureGroup Weather] [!UpdateMeter *] [!UpdateMeter *] [!Redraw] [!Log "Unable to connect to Weather.com." Error]
OnRegExpErrorAction=[!EnableMeasureGroup Weather] [!UpdateMeasureGroup Weather] [!UpdateMeter *] [!UpdateMeter *] [!Redraw] [!Log "Something went wrong." Error]

DynamicVariables=1
UpdateDivider=-1
Disabled=1

; ================================================

[mWeatherCurrentTemperature]
Group=Weather
Measure=WebParser
URL=[mWeatherParent]
StringIndex=1
RegExp=(?siU)"temperature":#WeatherRegExpNumber#[,}\]]
StringIndex2=1
RegExpSubstitute=1
Substitute="#WeatherSubstitute#", "^$":"--"
Thanks :thumbup:
Last edited by sl23 on June 25th, 2024, 12:38 pm, edited 2 times in total.
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16358
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skins Not Working

Post by balala »

sl23 wrote: June 25th, 2024, 10:17 am My weather skin has stopped working again, giving four errors:
Not sure at all this helps, but you may want to try restarting Rainmeter. I mean a complete restart: close it from the Notification Area icon and restart it from the Start Menu.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2676
Joined: March 23rd, 2015, 5:26 pm

Re: Weather Skins Not Working

Post by SilverAzide »

jsmorley wrote: June 25th, 2024, 4:50 am
balala wrote: June 25th, 2024, 9:23 am
OK, I'm a bit mystified. If you search for "New York, NY", you only get a single search result whereas you used to get the maximum of 10. If you search for "New York", you get two results. If you search for "San Francisco" or "London" you get 10 results. I did a search for "Virginia" and I got all sorts of crazy results including some in Arabic, none of which were the US state.

Reading the OSM forums, it looks like OSM got hacked a few weeks ago (more like vandalism) and they are fixing the damage, so perhaps this has something to do with it. In any event, the API is at least working and returning results for me.

One caution I did notice while reviewing their API docs, is that their "search.php" URI is (has already been) deprecated and will stop working at some point. Most Rainmeter skins use this. The new URI simply drops the ".php" to conform to REST conventions.
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 7555
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Weather Skins Not Working

Post by Yincognito »

sl23 wrote: June 25th, 2024, 10:17 am My weather skin has stopped working again, giving four errors:

Code: Select all

Something went wrong. (RM\Weather\Weather.ini)
RegExp matching error (-1) (RM\Weather\Weather.ini - [mWeatherParent])
No results found for that location. (RM\Weather\Weather.ini)
RegExp matching error (-1) (RM\Weather\Weather.ini - [mWeatherLocationParent])
Is this due to the API key changing again?
I doubt it's related to the key, my guess is that it's the same Nominatim issue, since the 1st error is about the location. Try changing the UserAgent in mWeatherLocationParent based on the previous replies about it (the last one or two pages in this thread), or wait for jsmorley and SilverAzide to come up with a stable solution, if one exists.

Frankly, I don't really see why the said code needs to poll Nominatim every time weather is retrieved, polling just once when the skin is installed or when the user's location changed (something that happens very rarely anyway) or even on a manual click when really needed, followed by !WriteKeyValue the found coordinates to be used going forward should be more than enough. Apart from the update rates (which, although rare at every 15 minutes, are pointless unless you're in a high speed train all the time and incidentally you wouldn't care about the weather too much), if all weather skins behave like that, there's a lot of redundant calls that don't actually achieve anything other than confirming the same location retrieved the last time weather was retrieved. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1226
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Weather Skins Not Working

Post by sl23 »

balala wrote: June 25th, 2024, 11:50 am Not sure at all this helps, but you may want to try restarting Rainmeter. I mean a complete restart: close it from the Notification Area icon and restart it from the Start Menu.
Hi balala, thanks for replying. :thumbup:
Tbh, this has been like it now for a week or two. It's been restarted and so has my PC. This has had no effect. :-(
- MuLab -
User avatar
sl23
Posts: 1226
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Weather Skins Not Working

Post by sl23 »

Yincognito wrote: June 25th, 2024, 12:02 pm I doubt it's related to the key, my guess is that it's the same Nominatim issue, since the 1st error is about the location. Try changing the UserAgent in mWeatherLocationParent based on the previous replies about it (the last one or two pages in this thread), or wait for jsmorley and SilverAzide to come up with a stable solution, if one exists.

Frankly, I don't really see why the said code needs to poll Nominatim every time weather is retrieved, polling just once when the skin is installed or when the user's location changed (something that happens very rarely anyway) or even on a manual click when really needed, followed by !WriteKeyValue the found coordinates to be used going forward should be more than enough. Apart from the update rates (which, although rare at every 15 minutes, are pointless unless you're in a high speed train all the time and incidentally you wouldn't care about the weather too much), if all weather skins behave like that, there's a lot of redundant calls that don't actually achieve anything other than confirming the same location retrieved the last time weather was retrieved. :confused:
Thanks for the advice. :)

Re: Nominatum, can't you use google instead for location, or is it a developer preference?

Re: Update, it may surprise you that I have absolutely no idea how this skin works! 8-) :rofl:
So I can set update to -1 then? Won't need to update throughout the day though? Is there anything else I can remove from the above code of mine just to slimline it? Or is it at it's minimum? When I say remove, I'm really talking about sections rather than surgically removing tiny bits of code. So just a quick skim should tell you if there is anything useless in it. Thanks :thumbup:
- MuLab -
User avatar
sl23
Posts: 1226
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Weather Skins Not Working

Post by sl23 »

No worries, the updated version works fine. ;-)
- MuLab -