It is currently July 17th, 2019, 1:43 pm

Weather Skin Tutorial

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
ZerOverdriver
Posts: 30
Joined: February 13th, 2017, 8:57 pm

Re: Weather Skin Tutorial

ZerOverdriver » June 13th, 2017, 2:58 pm

RegExp=#CurrentElements#
========================
StringIndex=6 <icon>(.*)</icon> Current moon phase icon number - Example: "12"
What is this maximum digits value? How many moon fazes icons should be?
User avatar
jsmorley
Developer
Posts: 19287
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Weather Skin Tutorial

jsmorley » June 13th, 2017, 3:19 pm

User avatar
CyberTheWorm
Posts: 651
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Weather Skin Tutorial

CyberTheWorm » June 13th, 2017, 3:40 pm

ZerOverdriver wrote:What is this maximum digits value? How many moon fazes icons should be?
29 I think
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
pvanheumen
Posts: 3
Joined: June 17th, 2017, 9:07 am

Re: Weather Skin Tutorial

pvanheumen » June 17th, 2017, 9:23 am

I'am using Rainmeter with this skin for a couple of weeks now on my laptop. It is working without any problem. But i'am working in different locations.
Is it possible that the skin follow my location, and perhaps display the name of city ?
Be kind whenever possible. It is always possible. Dalai Lama XIV
User avatar
CyberTheWorm
Posts: 651
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Weather Skin Tutorial

CyberTheWorm » June 17th, 2017, 3:11 pm

pvanheumen wrote:I'am using Rainmeter with this skin for a couple of weeks now on my laptop. It is working without any problem. But i'am working in different locations.
Is it possible that the skin follow my location, and perhaps display the name of city ?
Yes but you would have to re-write the skin.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
balala
Rainmeter Sage
Posts: 8368
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » June 17th, 2017, 4:31 pm

CyberTheWorm wrote:Yes but you would have to re-write the skin.
Not necessarily. Depending on more things, the skin should get the IP address, then based on it, should get the location and set up the necessary code.
pvanheumen wrote:I'am using Rainmeter with this skin for a couple of weeks now on my laptop. It is working without any problem. But i'am working in different locations.
Is it possible that the skin follow my location, and perhaps display the name of city ?
Try the followings: first add the following measure to the code of your skin:

Code: Select all

[MeasureIPad]
Measure=PLUGIN
Plugin=WebParser
Url=http://checkip.dyndns.org/
RegExp=(?siU)<html><head><title>Current IP Check</title></head><body>Current IP Address: (.*)</body></html>
StringIndex=1
FinishAction=[!EnableMeasure "MeasureIPinfo"][!CommandMeasure "MeasureIPinfo" "Update"][!UpdateMeasure "MeasureIPinfo"]
This measure will return your IP address. The [MeasureIPinfo] measure, which I used in the FinishAction option, doesn't exist yet, but adding it will be the next step. So, add it, as well as its child measure, [MeasureIPCity]:

Code: Select all

[MeasureIPinfo]
Measure=PLUGIN
Plugin=WebParser
Url=http://whatismyipaddress.com/ip/[&MeasureIPad]
RegExp=(?siU)<tr><th>Country:</th><td>(.*)<img src="(.*)" alt=".*">.*<tr><th>City:</th><td>(.*)</td></tr>
FinishAction=[!EnableMeasure "MeasureIPCity"][!UpdateMeasure "MeasureIPCity"][!UpdateMeter "MeterLocation"][!Redraw]
UpdateRate=3600
DynamicVariables=1
Disabled=1

[MeasureIPCity]
Measure=Plugin
Plugin=WebParser
Url=[MeasureIPinfo]
StringIndex=3
Disabled=1
IfMatch=#City1#
IfMatchAction=[!SetVariable WeatherLocation "#WeatherCode1#"][!EnableMeasure "MeasureLocation"][!UpdateMeasure "MeasureLocation"][!CommandMeasure "MeasureLocation" "Update"]
IfMatch2=#City2#
IfMatchAction2=[!SetVariable WeatherLocation "#WeatherCode2#"][!EnableMeasure "MeasureLocation"][!UpdateMeasure "MeasureLocation"][!CommandMeasure "MeasureLocation" "Update"]
...
See that the [MeasureIPinfo] measure initially is disabled. It is enabled through the FinishAction option of the [MeasureIPad] measure. When on the other hand, [MeasureIPinfo] finishes parsing the needed info, it enables its own child measure ([MeasureIPCity]), which returns the name of location. The IfMatch options then will compare the returned string with the predefined city names. If it finds the appropriate name, will set up the WeatherLocation variable, which is the code of the found city. At this point you have to define in the [Variables] section of your code, all citys and the appropriate weather codes where you want to use the skin:

Code: Select all

[Variables]
City1=PUT HERE THE EXACTE NAME OF THE FIRST CITY
City2=PUT THE NAME OF THE SECOND CITY
AND SO ON
...
WeatherCode1=PUT HERE THE WEATHER CODE OF THE CITY SET UP AS City1 ABOVE
WeatherCode2=PUT HERE THE WEATHER CODE OF THE CITY SET UP AS City2 ABOVE
AND AGAIN SO ON
...
Note that you can add as many citys as you wish, just take care to add exactly the same number of weather codes, numbered corespondentely.
Now you have to add further IfMatch and the appropriate IfMatchAction options to the above [MeasureIPCity] measure, so many as many CityXX / WeatherCodeXX variables have you defined in the [Variables] section.
You can find the needed values of the WeatherCodeXX variables here: https://weather.codes/, based on the name of the location / city.
The last thing will be to use the set up WeatherLocation variable in the parent WebParser measure. For this, use the following URL option: Url=http://wxdata.weather.com/wxdata/weather/local/#WeatherLocation#?cc=*&unit=#Unit#&dayf=1
Obviously the described procedure will work ONLY if your skin uses the wxdata.weather.com as weather forecast provider. If it doesn't, forget everything I said above.
As we know, Unit may be equal either with m (as metric - temperatures in Celsius degrees), or with i (imperial - temperatures in Fahrenheit degrees). But I think this is another story...

Try to follow this description and if anything goes wrong, please post the code of your weather skin, to can take a look. Good luck.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3405
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Weather Skin Tutorial

eclectic-tech » September 2nd, 2017, 12:34 pm

In an earlier post in this thread, member ZerOverdrive described a way to automatically get the Locale of the current user with a Registry measure.

This is a great way to have weather skins return the information in the users language so the author does not have to translate the terms.
(Here's an example illustroSimpleWeather skin using Locale to automatically translate...)

But that posted code will not work due to an Invalid RegHKey (see Valid RegHKeys). :x

Here is a Registry measure that should return the Locale code for the current user:

Code: Select all

[Variables]
Locale=[Measure_UserLocale]

[Measure_UserLocale]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Control Panel\International\User Profile
RegValue=Languages

Hope this helps someone trying to create a weather skin that automatically gets the users Locale. 8-)
nmdelrio
Posts: 55
Joined: June 28th, 2015, 12:51 pm
Location: Paranaque City, Philippines

Re: Weather Skin Tutorial

nmdelrio » June 11th, 2019, 6:16 am

Oh wow, this is a great weather skin tutorial. Great work and thank you.

One thing though is I haven't seen a skin that also shows the daily hourly forecast. Is this because weather.com does not provide a feed for it? if there is, where can I get it, that is hoping I would understand the RegEx'es for it?
User avatar
balala
Rainmeter Sage
Posts: 8368
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weather Skin Tutorial

balala » June 11th, 2019, 6:40 am

nmdelrio wrote:
June 11th, 2019, 6:16 am
One thing though is I haven't seen a skin that also shows the daily hourly forecast. Is this because weather.com does not provide a feed for it?
Yep, I think it doesn't. Nor me have seen a such skin.
nmdelrio wrote:
June 11th, 2019, 6:16 am
if there is, where can I get it, that is hoping I would understand the RegEx'es for it?
To better understand how this option can be created and how to work with it, there is a great tool, named RainRegExp. Give it a try, it worth.
nmdelrio
Posts: 55
Joined: June 28th, 2015, 12:51 pm
Location: Paranaque City, Philippines

Re: Weather Skin Tutorial

nmdelrio » June 11th, 2019, 6:55 am

Thanks for the info, Balala.