It is currently October 16th, 2019, 8:33 pm

Weather Skin Tutorial

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
balala
Rainmeter Sage
Posts: 8839
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » January 4th, 2017, 5:03 pm

jsmorley wrote:Well, to each his own certainly. My approach was to expose all 180+ data elements available in that feed, without having to deal with that many distinct regular expression captures, (don't forget that WebParser can only handle 99 StringIndexes in a single parent measure, and who in their right mind would want to create a RegExp with 99 captures anyway?) and do it in a way that the average user won't have to know the ins and outs of that complex feed and what everything means.
I supposed that that measures structure could have a this kind of explanation. It's ingenious, I'll have to study this approach a bit more.
User avatar
fonpaolo
Moderator
Posts: 1343
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Weather Skin Tutorial

fonpaolo » January 4th, 2017, 5:05 pm

eclectic-tech wrote:Okay, okay... the structure is weird! :)

@koutamarto
Now that we completely derailed this thread :x , let us know if you get it working.

If not, then follow fonpaolo's suggestion to post those include files...
I don't think it's needed unless he has modifed the original ones in jsmorley first post...
...so we have to understand where is the problem.
User avatar
balala
Rainmeter Sage
Posts: 8839
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » January 4th, 2017, 6:13 pm

fonpaolo wrote:I don't think it's needed unless he has modifed the original ones in jsmorley first post...
...so we have to understand where is the problem.
You're right, it seems sometimes I am very confused. I don't know why, but I didn't see the uploaded skin in jsmorley's first post. Now I downloaded it, replaced the code of the skin with that posted by koutamarto and it's working for me.
koutamarto, the code needs a few updates to show what you asked, but without any change, it shows the lowest temperature for day after tomorrow. Here just note that day=1 represents tomorrow, while day=2 represents day after.
To get the tomorrow forecast (condition), replace the RegExp option of the [Day1ConditionsParent] measure with RegExp=#Day1DayConditions# and the StringIndex option of the [Day1ConditionsChild] with StringIndex=2. Probably you'll also want to replace the Text option of the [Day1Temp] meter with Text=%1.
To get the highest temperature for tomorrow, replace the RegExp of the [Day1ConditionsParent] with RegExp=#Day1General# and the StringIndex of the [Day1ConditionsChild] with StringIndex=3.
koutamarto
Posts: 9
Joined: December 23rd, 2016, 5:53 am

Re: Weather Skin Tutorial

koutamarto » January 5th, 2017, 6:19 am

balala wrote:You're right, it seems sometimes I am very confused. I don't know why, but I didn't see the uploaded skin in jsmorley's first post. Now I downloaded it, replaced the code of the skin with that posted by koutamarto and it's working for me.
koutamarto, the code needs a few updates to show what you asked, but without any change, it shows the lowest temperature for day after tomorrow. Here just note that day=1 represents tomorrow, while day=2 represents day after.
To get the tomorrow forecast (condition), replace the RegExp option of the [Day1ConditionsParent] measure with RegExp=#Day1DayConditions# and the StringIndex option of the [Day1ConditionsChild] with StringIndex=2. Probably you'll also want to replace the Text option of the [Day1Temp] meter with Text=%1.
To get the highest temperature for tomorrow, replace the RegExp of the [Day1ConditionsParent] with RegExp=#Day1General# and the StringIndex of the [Day1ConditionsChild] with StringIndex=3.

Hi everyone. thanks for the responses. They are much appreciated. I have figured it out and am extremely embarrassed and none to keen to share the issue :P However the whole point of forums is the sharing of information so incase there is someone else out there who one day does the same thing I will tell.
within the WXDataWeatherVars.inc I had changed the DaysFeed option to 1 as originally I only wanted to have the 1 day. It completely slipped my mind. @balala Thanks for testing my code, this helped assure me there was nothing wrong with it from a working point of vie and that the issue must be elsewhere.

In one of your earlier posts you mentioned the structure of the measures were "weird" is there another way I could or should be doing it?

Thanks

Ps. I just noted that @eclectic-tech actually posted the fix but It did not register in my half sleep state. Thanks Dude.
User avatar
balala
Rainmeter Sage
Posts: 8839
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » January 5th, 2017, 3:05 pm

koutamarto wrote:In one of your earlier posts you mentioned the structure of the measures were "weird" is there another way I could or should be doing it?
There is the "classic" one, but jsmorley (the author) in his post explained why he chose this structure.
Now finally I'm not sure if the skin is working well. Does it?
User avatar
jsmorley
Developer
Posts: 19567
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weather Skin Tutorial

jsmorley » January 5th, 2017, 3:26 pm

balala wrote:There is the "classic" one, but jsmorley (the author) in his post explained why he chose this structure.
The key to understanding my approach, and why I went that route, is the often overlooked fact that a "child" WebParser measure can also be a "parent", in effect creating a Grandparent / Parent / Child relationship.

So what I do is to get the entire feed, as one big string, in the first "grandparent" measure. That way I only go out and hit the site one time, and everything in the feed is available to me. I don't have to go back out to the internet at all, and this makes the parsing down the line just orders of magnitude faster. WebParser ALWAYS downloads the entire site to %TEMP% in any case, no matter what your RegExp is, so why not get it all at once, and just make it all available as you need? Understand, that this not only hits the internet only one time, but also only hits your hard drive to read the contents of the downloaded site data in %TEMP% one time. It is just crazy efficient. Weather skins, no matter how much data you are using, should refresh pretty much instantly.

Then I have logically broken up the feed into some "sections". So there is one for general "location" information, one for the "current" data, then one each for the forecast information for each "day", starting with today and up to five more.

That makes the parsing of these "sections" much more manageable. Each only has a handful of bits of data to "capture", rather than trying to wade through the entire 180+ elements the entire feed returns. I have no interest in an approach where to get the high temperature forecast for day 2 means I need to laboriously count captures to figure out that I need StringIndex=68. In any case, the limit of StringIndex numbers in WebParser is 99, so you literally can't get all the data in one RegExp.

So I have the "grandparent" measure:

Code: Select all

[WeatherParent]
Measure=Plugin
Plugin=WebParser
URL=https://wxdata.weather.com/wxdata/weather/local/#LocationCode#?cc=*&unit=#UnitOfMeasure#&dayf=#DaysFeed#&locale=#Locale#
RegExp=(?siU)^(.*)$
And then I can create "parent" measures for an individual "section"

Code: Select all

[LocationParent]
Measure=Plugin
Group=Weather
Plugin=WebParser
URL=[WeatherParent]
RegExp=#Location#
As you can see, this is at once a "child", since it uses a parent measure for the URL, and also a "parent", since it has its own RegExp option. This is in effect chopping out the chuck of data related to "location" from the "grandparent", and creating a small subset of StringIndex numbers for just that information.

Then I can use a standard "child" measure to get a single bit of "location" information:

Code: Select all

[CityNameChild]
Measure=Plugin
Group=Weather
Plugin=WebParser
URL=[LocationParent]
StringIndex=2
This isn't something you need to do all the time when parsing some feed with WebParser, but for a weather feed, which can have just boatloads of individual data elements of interest, it is both much more efficient, and if you wrap your head around it, you will find that this is entirely re-usable, and can be used to create a simple skin with just the temperature and current conditions icon, or a massive skin that gives you everything you want to know for the next 6 days. You will find that what I created in WXDataWeatherRegExp.inc is a "one-size-fits-all" solution that can be used with any skin you create.

No reason why you can't decide up front that you only want say five elements from the feed, and just create a "standard" parent / child relationship that parses just those five bits of data. If that is what you want, that's fine. However, be aware that if you change your mind, or someone says "that is nice, but can you add blah to it?", you are in for a lot of editing and poring through the raw feed output to figure out where things are and what "captures" you need to add. For the average user, that WXData feed is not the easiest thing to follow. What do all those arcane tag names like <obst> in the feed mean?
koutamarto
Posts: 9
Joined: December 23rd, 2016, 5:53 am

Re: Weather Skin Tutorial

koutamarto » January 5th, 2017, 9:05 pm

balala wrote:There is the "classic" one, but jsmorley (the author) in his post explained why he chose this structure.
Now finally I'm not sure if the skin is working well. Does it?
Yep its working as i wanted thanks heaps.
Im on to making a music player now. Seems tricky getting cover art for Spotify. Ive seen players do it so i know its possible.
User avatar
balala
Rainmeter Sage
Posts: 8839
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » January 5th, 2017, 9:22 pm

koutamarto wrote:Yep its working as i wanted thanks heaps.
Im on to making a music player now. Seems tricky getting cover art for Spotify. Ive seen players do it so i know its possible.
I'm glad if it's working.
Be careful with Spotify: https://forum.rainmeter.net/viewtopic.php?p=131041#p131041
nkumar2171
Posts: 1
Joined: February 1st, 2017, 8:38 am

Re: Weather Skin Tutorial

nkumar2171 » February 1st, 2017, 8:58 am

Hello,
We have tried to throw the Rainmeter application related guide into the air. I came to know this desktop customization tool only a week ago. But it was pretty impressing and compelled me to present a detailed guide on the basic use. Hope you will like it



:bow: :bow: :bow: :bow:
User avatar
ZerOverdriver
Posts: 30
Joined: February 13th, 2017, 8:57 pm

Re: Weather Skin Tutorial

ZerOverdriver » June 8th, 2017, 6:55 pm

jsmorley Developer
Thank you for your work and such a good help, clear instructions and for taking care of all.

Want to offer a way to automatically detect the language for the weather.
This will make it easier for all users of the skin.

Earlier in one of my skins I made and automatic location detection (city and country) of the user, but it's not exactly worked.

Code: Select all

[Variables]

[Measure_UserLocale]
Measure=Registry
RegHKey=HKEY_USERS
RegKey=.DEFAULT\Control Panel\International
RegValue=LocaleName

Locale=[Measure_UserLocale]