It is currently March 28th, 2024, 10:48 am

Add wind speed/direction to a skin

Get help with creating, editing & fixing problems with skins
Post Reply
iBimmer
Posts: 4
Joined: May 13th, 2023, 6:21 pm

Add wind speed/direction to a skin

Post by iBimmer »

Hello, first time here. I'm not a coder. Can someone help me add wind speed direction to an existing skin?

Code: Select all

[Rainmeter]
Update=1000
Author=Connect-R
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
AccurateText=1
MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh] 
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!Refresh] 
LeftMouseDoubleClickAction=!ToggleConfig "Lasix\Settings" "Settings.ini"

[Variables]
@include=#@#Variables.inc
@include2=#@#Language\Language.inc
Scale=0.56

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureWeather]
Measure=Plugin
Plugin=WebParser
URL=https://www.yahoo.com/news/weather/united-states/california/los-angeles-12795992
RegExp=(?siU)<div id=module-location-heading class=".*"><div><h1 class=".*">(.*)</h1>.*<div class="My\(2px\).*60x60\/(.*)@2x.png.*<p class=".*">(.*)</p></div>.*</div><div class="temperature-forecast.*"> <span class=".*fahrenheit celsius.*">(.*)</span> 
UpdateRate=900

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=1
DynamicVariables=1

[MeasureWeatherIcons]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=2
DynamicVariables=1
Substitute="rain_day_night":"rain","scattered_showers_day_night":"rain","windy_day_night":"wind","mostly_cloudy_day_night":"cloudy","cloudy_day_night":"cloudy","snow_rain_mix_day_night":"sleet","fair_day":"clear_day","fair_night":"clear_night","flurries_day_night":"snow","snow_day_night":"snow","thundershowers_day_night":"rain","fog_day_night":"fog"

[MeasureWeatherCond]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=3
DynamicVariables=1
Substitute=#Conditions#

[MeasureTempFahrenheit]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=4
DynamicVariables=1

[MeasureTempCelsius]
Measure=Calc
Formula=Round((MeasureTempFahrenheit-32)*5/9)
Substitute="-18":""

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterCurrentIcon]
Meter=Image
MeasureName=MeasureWeatherIcons
Path=#@#WeatherIcons
X=(0*#Scale#)
Y=(0*#Scale#)
W=(150*#Scale#)
AntiAlias=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterLocation]
Meter=String
MeasureName=MeasureLocation
StringAlign=Left
StringCase=Upper
FontFace=Montblanc
FontColor=#Color1#
FontSize=(28*#Scale#)
X=(150*#Scale#)
Y=(30*#Scale#)
Text="%1"
AntiAlias=1

[MeterCurrentCond]
Meter=String
MeasureName=MeasureWeatherCond
MeasureName2=#MeasureName2#
StringAlign=Left
StringCase=Upper
FontFace=Montblanc
FontColor=#Color1#
FontSize=(16*#Scale#)
X=(150*#Scale#)
Y=(90*#Scale#)
Text="%1 %2°#TempSymbol#"
AntiAlias=1


User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Add wind speed/direction to a skin

Post by eclectic-tech »

Several changes are needed to obtain the wind direction and speed from Yahoo.

The RegExp in the [MeasureWeather] section needs to be expanded to capture the wind direction (in degrees) and speed in MPH and KPH.
Replace [MeasureWeather] section with:

Code: Select all

[MeasureWeather]
Measure=Plugin
Plugin=WebParser
URL=https://www.yahoo.com/news/weather/united-states/california/los-angeles-12795992
RegExp=(?siU)<div id=module-location-heading class=".*"><div><h1 class=".*">(.*)</h1>.*<div class="My\(2px\).*60x60\/(.*)@2x.png.*<p class=".*">(.*)</p></div>.*</div><div class="temperature-forecast.*"> <span class=".*fahrenheit celsius.*">(.*)</span>.*<div class="item wind">.*style="transform: rotate\((.*)deg\)">.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>
UpdateRate=900
This adds captures for direction and both speed values in StringIndexes 5, 6, and 7.

New child measures are needed to provide these new values. I include a measure to convert the direction from degrees to compass cardinal directions (borrowed from Kaelri).

New measures, add them right after the [MeasureTempCelsius] section in the skin:

Code: Select all

[MeasureWindDirection]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=5

[MeasureCardinal]
Measure=Calc
Formula=FLOOR(((MeasureWindDirection/11.25)+1.5) < 33 ? ((MeasureWindDirection/11.25)+1.5) : ((MeasureWindDirection/11.25)+1.5)-32)
Substitute="10":"EbS","11":"ESE","12":"SEbE","13":"SE","14":"SEbS","15":"SSE","16":"SbE","17":"S","18":"SbW","19":"SSW","20":"SWbS","21":"SW","22":"SWbW","23":"WSW","24":"WbSW","25":"W","26":"WbN","27":"WNW","28":"NWbW","29":"NW","30":"NWbN","31":"NNW","32":"NbW","1":"N","2":"NbE","3":"NNE","4":"NEbN","5":"NE","6":"NEbE","7":"ENE","8":"EbN","9":"E"

[MeasureWindSpeedMPH]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=6

[MeasureWindSpeedKPH]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeather]
StringIndex=7

Save the changes.

When you refresh the skin, you will see the new values in the "Skin" tab of the Rainmeter log, but until you create new meters to display the values the skin will be unchanged.

Creating new meters I will leave up to you. :welcome:
iBimmer
Posts: 4
Joined: May 13th, 2023, 6:21 pm

Re: Add wind speed/direction to a skin

Post by iBimmer »

Thanks for you effort. I have no idea how to create new meters, and you were right, skin is unchanged after I refreshed it. Do you mind to point me to the right direction? I had just installed RM before I posted this, so please ELI5. Thanks again. :?
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: Add wind speed/direction to a skin

Post by SilverAzide »

iBimmer wrote: May 14th, 2023, 10:50 pm Thanks for you effort. I have no idea how to create new meters, and you were right, skin is unchanged after I refreshed it. Do you mind to point me to the right direction? I had just installed RM before I posted this, so please ELI5. Thanks again. :?
So what have you tried? There are some existing meters right there in the skin you could copy to get started. Did you look at the manual?

Otherwise, read this: Skin Requests.
iBimmer
Posts: 4
Joined: May 13th, 2023, 6:21 pm

Re: Add wind speed/direction to a skin

Post by iBimmer »

Not sure why is it so complicated. I just wanted to add a wind direction and speed to an existing skin. Just below the temperature or wherever. I don't even know what to try.

EDIT: I think I figured it out. It seems to work, only thing is that Wind direction is displayed as numberical value instead of N, S, SW, etc. Can this be changed?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Add wind speed/direction to a skin

Post by eclectic-tech »

iBimmer wrote: May 15th, 2023, 3:18 am Not sure why is it so complicated. I just wanted to add a wind direction and speed to an existing skin. Just below the temperature or wherever. I don't even know what to try.

EDIT: I think I figured it out. It seems to work, only thing is that Wind direction is displayed as numberical value instead of N, S, SW, etc. Can this be changed?
In the meter displaying wind direction, use Measurename=MeasureCardinal to show compass directions instead of numbers.
iBimmer
Posts: 4
Joined: May 13th, 2023, 6:21 pm

Re: Add wind speed/direction to a skin

Post by iBimmer »

That worked. Thanks, appreciated.
Post Reply