It is currently April 18th, 2024, 11:11 am

[Solved] Weather Skin help

Get help with creating, editing & fixing problems with skins
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

[Solved] Weather Skin help

Post by CyberTheWorm »

OK so I'm doing a weather skin, got all the values I was looking for but it will not display the data?

Am I missing something? I know the code is not elegant but I'm just learning this stuff.
Capture2.PNG
Capture.PNG

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1


[Metadata]


[Variables]

; LocationCode can be obtained at http://wxdata.weather.com/wxdata/search/search?where=YourCityName
LocationCode=CAXX0485

; UnitOfMeasure can be "i" (Imperial / Fahrenheit) or "m" (Metric / Celsius)
UnitOfMeasure=m

; Number of days to return in the feed.(1-6)
DaysFeed=1

; Locale (language) to use in the feed.
; https://msdn.microsoft.com/en-us/goglobal/bb896001.aspx
; Note that Weather.com uses "_" underline instead of "-" dash in the codes.
Locale=en_US

WebSite=https://wxdata.weather.com/wxdata/weather/local/#LocationCode#?cc=*&unit=#UnitOfMeasure#&dayf=#DaysFeed#&locale=#Locale#

; =======================================
; Measures
; =======================================

[MeasureTemp]
Measure=Plugin
Plugin=WebParser
URL=#WebSite#
RegExp=(?siU)<tmp>(.*)</tmp>

[MeasureFeelsLike]
Measure=Plugin
Plugin=WebParser
URL=#WebSite#
RegExp=(?siU)<flik>(.*)</flik>

[MeasureSunRise]
Measure=Plugin
Plugin=WebParser
URL=#WebSite#
RegExp=(?siU)<sunr>(.*)</sunr>

[MeasureSunSet]
Measure=Plugin
Plugin=WebParser
URL=#WebSite#
RegExp=(?siU)<suns>(.*)</suns>

[MeasureCurrentTemp]
Measure=Plugin
Plugin=WebParser
URL=[MeasureTemp]
StringIndex=1

[MeasureFeelsLikeTemp]
Measure=Plugin
Plugin=WebParser
URL=[MeasureFeelsLike]
StringIndex=1

[MeasureCurrentSunRise]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSunRise]
StringIndex=1

[MeasureCurrentSunSet]
Measure=Plugin
Plugin=WebParser
URL=[MeasureSunSet]
StringIndex=1

; =======================================
; Meters
; =======================================

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,200,120,2,2 | Fill color 127,127,127,255 | StrokeWidth 2 | Stroke Color 200,200,200,255
X=1
Y=1

[MeterTempLabel]
Meter=String
X=50
Y=5
FontFace=Ariel
FontSize=10
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Center
StringEffect=Shadow
FontEffectColor=0,0,0,255
Text=Current Temp:

[MeterTemp]
Meter=String
MeasureName=MeasureCurrentTemp
X=180
Y=0r
FontFace=Ariel
FontSize=10
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Right
StringEffect=Shadow
FontEffectColor=0,0,0,255
Text=%1 C

You do not have the required permissions to view the files attached to this post.
Last edited by CyberTheWorm on February 21st, 2017, 10:08 am, edited 1 time in total.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Weather Skin help

Post by fonpaolo »

What you're trying to obtain it's a little more complicate...
This is the code I'm currently using:
1- a measure using the link to the weather xml, with location code, number of days for forecast and unit of measures, it downloads all;

Code: Select all

[MeasureWeather]
Measure=Plugin
Plugin=WebParser
Url=#WebSite#
RegExp=(?siU)^(.*)$
UpdateRate=1800
2- a measure, using the downloaded data to parse all the informations you want, as this:

Code: Select all

[MeasureBase]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWeather]
RegExp=(?siU).*<locale>(.*)</locale>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*<loc id="(.*)">.*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*<ppcp>(.*)</ppcp>.*
Substitute="":"-1"

[MeasureToday]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWeather]
RegExp=(?siU)<dayf>.*<lsup>(.*)</lsup>.*<day d="0" t="(.*)" dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>(?(?=.*<part p="d">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>)(?(?=.*<part p="n">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*)
Substitute="":"-1"

[MeasureForecastDay1]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWeather]
RegExp=(?siU)<day d="1" t="(.*)" dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>(?(?=.*<part p="d">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>)(?(?=.*<part p="n">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*)
Substitute="":"-1"

[MeasureForecastDay2]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWeather]
RegExp=(?siU)<day d="2" t="(.*)" dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>(?(?=.*<part p="d">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>)(?(?=.*<part p="n">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*)
Substitute="":"-1"

[MeasureForecastDay3]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWeather]
RegExp=(?siU)<day d="3" t="(.*)" dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>(?(?=.*<part p="d">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>)(?(?=.*<part p="n">).*<icon>(.*)</icon>.*<t>(.*)</t>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*)
Substitute="":"-1"
3- one measure, for every single data you want to display, for example:

Code: Select all

[MeasureLocationName]
Measure=Plugin
Plugin=WebParser
Url=[MeasureBase]
StringIndex=8
Otherwise, if you want to use a measure for every single data, if you look at this: Weather Skin Tutorial by jsmorley, you'll find all the steps.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Weather Skin help

Post by fonpaolo »

Another suggestion, to shorten your code, since there's already a lot of code to display everything, you can combine two meters in one, from your code:

Code: Select all

[MeterTemp]
Meter=String
MeasureName=MeasureCurrentTemp
X=50
Y=5
FontFace=Ariel
FontSize=10
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Center
StringEffect=Shadow
FontEffectColor=0,0,0,255
Text=Current Temp: %1 °C
It's up to you if it's better or not and if use Center, Right or Left align.
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Weather Skin help

Post by FreeRaider »

the simplest solution is: change the Update from -1 to

Code: Select all

Update=1000
Out of curiosity: why you use a lot of measures if the same result can be achieved with a parent measure and four "children" measures?
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Weather Skin help

Post by fonpaolo »

FreeRaider wrote:the simplest solution is: change the Update from -1 to

Code: Select all

Update=1000
Out of curiosity: why you use a lot of measures if the same result can be achieved with a parent measure and four "children" measures?
Thanks FreeRaider, I missed that! :rofl:

As you also noted, it's better to use a single measure to download everything and then extract from that, all the needed informations.

Another suggestion that should be used when building and testing any skin getting data from a web source:
- first download the data as an .xml file, then point your webParser to use the file instead of hit the site too often. ;-)
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Weather Skin help

Post by FreeRaider »

fonpaolo wrote:Thanks FreeRaider, I missed that! :rofl:

As you also noted, it's better to use a single measure to download everything and then extract from that, all the needed informations.

Another suggestion that should be used when building and testing any skin getting data from a web source:
- first download the data as an .xml file, then point your webParser to use the file instead of hit the site too often. ;-)
You can use Debug option :)
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Weather Skin help

Post by CyberTheWorm »

FreeRaider wrote:the simplest solution is: change the Update from -1 to

Code: Select all

Update=1000
Out of curiosity: why you use a lot of measures if the same result can be achieved with a parent measure and four "children" measures?
When you are learning better not to add everything in 1 shot. Now I know what I did wrong, I can tweak the code to simplify the code.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Weather Skin help

Post by CyberTheWorm »

fonpaolo wrote:Thanks FreeRaider, I missed that! :rofl:

As you also noted, it's better to use a single measure to download everything and then extract from that, all the needed informations.

Another suggestion that should be used when building and testing any skin getting data from a web source:
- first download the data as an .xml file, then point your webParser to use the file instead of hit the site too often. ;-)
Right good idea
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Weather Skin help

Post by FreeRaider »

CyberTheWorm wrote:When you are learning better not to add everything in 1 shot. Now I know what I did wrong, I can tweak the code to simplify the code.
Glad to help.

A bit of advice:

https://docs.rainmeter.net/tips/webparser-debugging-regexp/
https://docs.rainmeter.net/manual/skins/option-types/#RegExp

and an external URL https://regex101.com/ (useful for the RegExp option)
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Solved] Weather Skin help

Post by fonpaolo »

Maybe you're already aware, CyberTheWorm, to test, find and display all the data you want, you can use this tool: RainRegExp
If you're building a RegExp from scratch, if you're finding a specific StringIndex or trying to add/modify something, it's the best help.
Edit: I add this after FreeRaider beat me. ;-)