It is currently April 25th, 2024, 7:32 am

weather skin question(s)

Get help with creating, editing & fixing problems with skins
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: weather skin question(s)

Post by JamX »

I have modified the forcast to:

Code: Select all

Forecast=(?siU)(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>).*(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">.*</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>.*</sup></span>.*<span class="">(.*)<sup>.*</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">.*</span>).*(?=.*className="wind"><span class="">(.*)</span>.*)(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>.*</sup></span>.*<span class="">(.*)<sup>.*</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">.*</span>).*(?=.*className="wind"><span class="">(.*)</span>.*)(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>.*</sup></span>.*<span class="">(.*)<sup>.*</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">.*</span>).*(?=.*className="wind"><span class="">(.*)</span>.*)
It returns the WIND values as: SSW 32 km/h for all 3 days.

Now I need to split this string into SSW and 32, without the km/h

With the @currentwinddirection code as below you'll get SSW

Code: Select all

[@CurrentWindDirection]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^(.*) .*$":"\1"
Can you do 2 times substitute so the SSW is directly substituted to degrees like?

Code: Select all

@CurrentWindDirection]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^(.*) .*$":"\1"
Substitute="NNE":"22.5","ENE":"67.5","ESE":"112.5","SSE":"157.5","SSW":"202.5","WSW":"247.5","WNW":"292.5","NNW":"337.5","NE":"45","SE":"135","SW":"225","NW":"315","N":"0","E":"90","S":"180","W":"270"
How do I adjust the Substitute="(?iU)^.*([\d]+ .*)$":"\1" from below code so I get 32 or even better 32/1.852 so I'll get directly knots as windspeed

Code: Select all

[@CurrentWind]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^.*([\d]+ .*)$":"\1"
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: weather skin question(s)

Post by balala »

Not sure. Please post a larger (complete) code, not distinct measures / meters, which are extremely hard to follow.
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: weather skin question(s)

Post by JamX »

OK, I'm almost there, I think :lol:

I have done this:

Code: Select all

[@CurrentWindDirection]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^(.*) .*$":"\1"

[@CurrentWindDG]
Measure=String
String=[@CurrentWindDirection]
Substitute="NNE":"22.5","ENE":"67.5","ESE":"112.5","SSE":"157.5","SSW":"202.5","WSW":"247.5","WNW":"292.5","NNW":"337.5","NE":"45","SE":"135","SW":"225","NW":"315","N":"0","E":"90","S":"180","W":"270"
DynamicVariables=1

[@CurrentWind]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^.*(\d+) .*$":"\1"
Where:
String16 results in "SSW 32 km/h"
[@CurrentWindDirection] results in SSW
[@CurrentWindDG] results in "202.5"
[@CurrentWind] results in 32

The [@CurrentWindDG] results in "202.5" it is a STRING value NOT a number so I can not use it with my rotator. Somehow I need to format this STING into a NUMBER value.

[@CurrentWind] results in "32" , Also a STRING value. How do I rewrite the Substitute="(?iU)^.*(\d+) .*$":"\1" so I will get 32 as NUMBER value and devide it by 1.852 to get knots in stead of km/h

Any Ideas?
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: weather skin question(s)

Post by balala »

JamX wrote: February 20th, 2020, 7:03 pm The [@CurrentWindDG] results in "202.5" it is a STRING value NOT a number so I can not use it with my rotator. Somehow I need to format this STING into a NUMBER value.

[@CurrentWind] results in "32" , Also a STRING value. How do I rewrite the Substitute="(?iU)^.*(\d+) .*$":"\1" so I will get 32 as NUMBER value and devide it by 1.852 to get knots in stead of km/h

Any Ideas?
For sure. Pass it through a Calc measure. For instance:

Code: Select all

[@CurrentWindDGNum]
Measure=Calc
Formula=[@CurrentWindDG]
DynamicVariables=1
Use the [@CurrentWindDGNum] measure into the Rotator meter. If you do this don1t forget to add the needed MinValue and MaxValue options, probably MinValue=0 and MaxValue=360.
Same way you need a suplimentar Calc measure for [@CurrentWind] as well. Hoping you figured out how.
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: weather skin question(s)

Post by JamX »

balala wrote: February 20th, 2020, 8:42 pm For sure. Pass it through a Calc measure. For instance:

Code: Select all

[@CurrentWindDGNum]
Measure=Calc
Formula=[@CurrentWindDG]
DynamicVariables=1
Use the [@CurrentWindDGNum] measure into the Rotator meter. If you do this don1t forget to add the needed MinValue and MaxValue options, probably MinValue=0 and MaxValue=360.
Same way you need a suplimentar Calc measure for [@CurrentWind] as well. Hoping you figured out how.
I've done exactly what you stated above and it works.

All is finished.

The Substitute="(?iU)^.*(\d+) .*$":"\1" I figured out by trail and error.
I still do not know exactly what it all means.

^ Start of the string
.* skip all before (\d+)
(\d+) two digits, without the + it does not work
.*$ skip to end of string
\1 first part??

I'm I correct?

Is there somewhere a manual for these commands?
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: weather skin question(s)

Post by balala »

JamX wrote: February 20th, 2020, 9:01 pm I've done exactly what you stated above and it works.
I'm glad. Good work. :thumbup:
JamX wrote: February 20th, 2020, 9:01 pm (\d+) two digits, without the + it does not work
Beside the links posted by jsmorley, note that in fact (\d+) means not two digits, but one or more. Might be one, two, three or even more. If you don't add the +, it means exactly one digit, that's why it doesn't work so.
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: weather skin question(s)

Post by Yincognito »

mak_kawa wrote: February 20th, 2020, 12:27 pmSo, how about Substitute=" km/h":""?
The substitution of " km/h" with "" won't work because the / in that string is encoded as \u002F (i.e. the Unicode code for /), even after using DecodeCharacterReference=1 on the WebParser child measure. This has been discussed here already.

In other words, balala's solution for this string is correct, as it searches for the digits followed by space (i.e. \d+ ) in the string and not the km/h part (which is actually something like km\u002Fh in the string).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
JamX
Posts: 207
Joined: October 4th, 2019, 2:46 pm

Re: weather skin question(s)

Post by JamX »

I thought I had it but a small problem persists.

The current windspeed is not correct value.

From RainRegExp string 16 is returned as SSW 32 km/h
In the Log file of the skin you can see the split up of that string into
@CurrentWindDirection -> SSW = OK
@CurrentWindDG -> 202.5 = OK
@CurrentWindKMH -> 2 = NOK should be 32 since string 16 is SSW 32 km/h
Capture.JPG
This is the code I'v used for the split up:

Code: Select all

[@CurrentWindDirection]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@CurrentParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^(.*) .*$":"\1"

[@CurrentWindDG]
Measure=String
String=[@CurrentWindDirection]
Substitute="NNE":"22.5","ENE":"67.5","ESE":"112.5","SSE":"157.5","SSW":"202.5","WSW":"247.5","WNW":"292.5","NNW":"337.5","NE":"45","SE":"135","SW":"225","NW":"315","N":"0","E":"90","S":"180","W":"270"
DynamicVariables=1

[@CurrentWindDGN]
Measure=Calc
Formula=[@CurrentWindDG]
DynamicVariables=1
MinValue=0
MaxValue=360

[@CurrentWindKMH]
Measure=WebParser
Group=Weather | WeatherCurrent
Url=[@ForecastParent]
StringIndex=16
RegExpSubstitute=1
Substitute="(?iU)^.*(\d+) .*$":"\1"
Somehow the Substitute="(?iU)^.*(\d+) .*$":"\1" is not working but it work in the forecasting code. there I use the same Substitute

Anybody an idea why it is not working?

Here is the skin.
weather_.rmskin
You do not have the required permissions to view the files attached to this post.