It is currently March 28th, 2024, 3:42 pm

Getting "Feels Like" for Temperature to show up

Get help with creating, editing & fixing problems with skins
Post Reply
Mordecai7562
Posts: 9
Joined: March 13th, 2018, 4:44 am

Getting "Feels Like" for Temperature to show up

Post by Mordecai7562 »

I'm back. I figured out how to fix the other problems I had, but now I want to add another function to the temperature display which would show what the temperature currently feels like.

Here's the code I have in it already:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
ContextTitle=USA unit
ContextAction=[!WritekeyValue TempText MeasureName MeasureTemp][!Refresh]
ContextTitle2=Rest of the world unit
ContextAction2=[!WritekeyValue TempText MeasureName MeasureTempC][!Refresh]
ContextTitle3=Location	[MeasureLocation]
ContextAction3=["https://www.yahoo.com/news/weather"]

[Variables]
Unit=1
FontName=Cartoonist
FontHeight=28
AntiAlias=1
IconColor=black
Scale=3/5

[Background]
Meter=IMAGE
ImageName=ramcpu4.png
AntiAlias=1


[MeasureBATT]
Measure=Plugin
Plugin=PowerPlugin
PowerState=Percent
RegExpSubstitute=1
Substitute="^(\d\d)$":"0\0","^(\d)$":"00\0"

[Label Temp]
Meter=STRING
X=0
Y=0
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontHeight#
StringAlign=LEFT
StringStyle=Italic
StringEffect=Border
FontEffectColor=206, 134, 99, 160
AntiAlias=1

[Label BATT]
Meter=STRING
X=28
Y=55
FontColor=#FontColor#
FontFace=#FontName#
FontSize=#FontHeight#
StringAlign=LEFT
StringStyle=Italic
StringEffect=Border
FontEffectColor=206, 134, 99, 160
AntiAlias=1

[Temp]
Meter=String
MeasureName=MeasureTemp
DynamicVariables=1
X=115
Y=171
FontColor=106,254,221
FontFace=#FontName#
FontSize=#FontHeight#
StringAlign=RIGHT
StringStyle=Italic
AntiAlias=1
Text="%1"
Angle=(Rad(-11))
MinValue=-30
MaxValue=120

[BATT]
Meter=STRING
MeasureName=MeasureBATT
X=195
Y=158
FontColor=254,100,231
FontFace=#FontName#
FontSize=#FontHeight#
StringAlign=RIGHT
StringStyle=Italic
AntiAlias=1
Text="%1"
Percentual=1
AutoScale=1
Angle=(Rad(-11))

[MeterBar]
MeasureName=MeasureTemp
Meter=BAR
X=62
Y=197
W=150
H=5
BarOrientation=HORIZONTAL
BarImage=cpupersona.png

[MeterBar2]
MeasureName=MeasureBATT
Meter=BAR
X=84
Y=204
W=150
H=5
BarOrientation=HORIZONTAL
BarImage=rampersona.png

[MeterBar3]
MeasureName=MeasureFeelLike
Meter=BAR
X=106
Y=240
W=150
H=5
BarOrientation=HORIZONTAL
BarImage=tmppersona.png

[Weather]
Measure=Plugin
Plugin=Webparser
URL=https://www.yahoo.com/news/weather/united-states/wisconsin/milwaukee-12780900
;Your location is automatically located. If it's incorrect or you want a custom place, access to https://www.yahoo.com/news/weather
;Click "Change Location", type in then choose where you want. After that, copy new webpage link and replace it with this measure URL. And refresh skin!
RegExp=(?siU)<h1 class="city.*data-reactid="7">(.*)</h1>.*<div class="My\(2px\).*60x60\/(.*)@2x.png.*data-reactid="26">(.*)<.*<span class="Va\(t\)" data-reactid="37">(.*)</span>
UpdateRate=60

[MeasureLocation]
Measure=Plugin
Plugin=Webparser
URL=[Weather]
StringIndex=1
DynamicVariables=1

[MeasureIcon]
Measure=Plugin
Plugin=Webparser
URL=[Weather]
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"
OnChangeAction=[!UpdateMeter Icon]

[MeasureDes]
Measure=Plugin
Plugin=Webparser
URL=[Weather]
StringIndex=3
DynamicVariables=1

[MeasureTemp]
Measure=Plugin
Plugin=Webparser
URL=[Weather]
StringIndex=4
DynamicVariables=1
MinValue=-30
MaxValue=120

[MeasureTempC]
Measure=Calc
Formula=Round((MeasureTemp-32)*5/9)
OnChangeAction=[!CommandMeasure Phrase getphrase()]

[Icon]
Meter=Image
DynamicVariables=1
W=(100*#Scale#)
Y=(500*#Scale#-[MeterString:H]-100*#Scale#)
ImageRotate=-15
UpdateDivider=-1
Group=Text

[TempText]
Meter=String
MeasureName=MeasureTemp
Text=%1
FontFace=HelveticaNeueLT Com 75 Bd
StringAlign=LeftBottom
FontColor=ffffff
FontSize=(35*#Scale#)
AntiAlias=1
X=(20*#Scale#)R
Y=(500*#Scale#-[MeterString:H]-5*#Scale#)
DynamicVariables=1
Hidden=1
UpdateDivider=-1
Group=Text
MinValue=-30
MaxValue=120

[MeterString]
Meter=String
;Text=Fetching...
;FontFace=HelveticaNeueLT Com 75 Bd
FontSize=(50*#Scale#)
FontColor=ffffff
StringAlign=LeftBottom
AntiAlias=1
Y=(500*#Scale#)
;Group=Text
UpdateDivider=-1

[Subline]
;Meter=String
FontFace=HelveticaNeueLT Com 75 Bd
FontSize=(16*#Scale#)
Y=(500*#Scale#)
FontColor=bababa
AntiAlias=1
Group=Text
UpdateDivider=-1

[Phrase]
Measure=Script
ScriptFile=phrases.lua
What variables/functions (or whatever they're called in rainmeter) do I need to add to apply the "Feels Like" functionality?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Getting "Feels Like" for Temperature to show up

Post by eclectic-tech »

You need to look through the source code for the Yahoo weather webpage you are using, look for that information buried in the HTML code, then add the proper code to your webparser regexp to capture that info...

Of course as soon as Yahoo makes a change to that page design, your skin is going to stop working. :x

That is the main reason why it has been suggested to start with a working weather skin that uses a reliable data feed! :?
Mordecai7562
Posts: 9
Joined: March 13th, 2018, 4:44 am

Re: Getting "Feels Like" for Temperature to show up

Post by Mordecai7562 »

Alrighty, I'll start looking through the html for "feels like".
I modified another one that had feels like implemented, but it's too high by ten degrees even though it's coming from yahoo weather, so I'll look and try some changes to see if I can make it more accurate.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Getting "Feels Like" for Temperature to show up

Post by balala »

eclectic-tech wrote:Of course as soon as Yahoo makes a change to that page design, your skin is going to stop working. :x
This is why a data feed with xml format (like wxdata.weather.com) would be much - much better. Its format never changes.
Mordecai7562
Posts: 9
Joined: March 13th, 2018, 4:44 am

Re: Getting "Feels Like" for Temperature to show up

Post by Mordecai7562 »

Is there a way to use a lua script for feels like? the one skin I'm using as a reference has a lua script for max/min temperatures
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting "Feels Like" for Temperature to show up

Post by jsmorley »

Mordecai7562 wrote:Is there a way to use a lua script for feels like? the one skin I'm using as a reference has a lua script for max/min temperatures
There is...

Code: Select all

function Initialize()

	MeasureTemp = SKIN:GetMeasure("MeasureNowWeatherTemp")
	MeasureHumidity = SKIN:GetMeasure("MeasureNowHumidity")
	MeasureWind = SKIN:GetMeasure("MeasureNowWind")
	MeasureConditions = SKIN:GetMeasure("MeasureNowWeatherConditions")
	StartingUnit = SKIN:GetVariable("Unit")

end -->Initialize

function Update()

	SkinTemp = MeasureTemp:GetValue()
	SkinWind = MeasureWind:GetValue()
	Humid = MeasureHumidity:GetValue()
	
	if string.upper(StartingUnit) == "C" then
		TempF = Round((9/5)*SkinTemp+32)
		WindM = Round(SkinWind * 1.60934400061)
	else
		TempF = SkinTemp
		WindM = SkinWind
	end
	
	--Uncomment to test with different inputs
	--SkinTemp = 95
	--TempF = 95
	--Humid = 50
	--WindM = 14
	
	if TempF > 80 and Humid > 40 then
		Feels = -42.379 + 2.04901523 * TempF + 10.14333127 * Humid - 0.22475541 * TempF * Humid - 6.83783 * 10^(-3)*(TempF^(2)) - 5.481717 * 10^(-2)*(Humid^(2)) + 1.22874 * 10^(-3)*(TempF^(2))*(Humid) + 8.5282 * 10^(-4)*(TempF)*(Humid^(2)) - 1.99 * 10^(-6)*(TempF^(2))*(Humid^(2))
	elseif  TempF < 41 and WindM > 4 then
		Feels = 35.74 + 0.6215 * TempF - 35.75 * WindM ^ 0.16 + 0.4275 * TempF * WindM ^ 0.16
	else
		Feels = TempF
	end	
	
	if string.upper(StartingUnit) == "C" then
		Feels = Round((5/9)*(Feels-32))
	else
		Feels = Round(Feels)
	end	
	
	SKIN:Bang("!SetOption MeterNowFeels Text \""..Feels.."°\"")	
	
	CurrConditions = MeasureConditions:GetStringValue()

	if string.len(CurrConditions) > 15 then
		SKIN:Bang("!SetOption MeterNowConditions FontSize 12")
	else
		SKIN:Bang("!SetOption MeterNowConditions FontSize 14")
	end

	return Feels
	
end -->Update

function Round(num, idp)
	assert(tonumber(num), 'Round expects a number.')
	local mult = 10^(idp or 0)
	if num >= 0 then
		return math.floor(num * mult + 0.5) / mult
	else
		return math.ceil(num * mult - 0.5) / mult
	end
end
This is from the National Oceanic and Atmospheric Administration (NOAA). What it is really is two formulas, one that calculates a "heat index" if the temperature and percent humidity is above a certain point, and one that calculates a "wind chill" if the temperature is below a certain point and the wind speed is above a certain point. The net result will be very similar to what you see as "feels like" on weather sites.

These formulas are based on Fahrenheit and MPH, so if you are returning Celsius and KPH, you have to convert back and forth before and after the formula.

I have no earthly idea what these formulas are doing or what the static values represent, so don't bother asking me... ;-) I only know that they work.

https://www.weather.gov/ama/heatindex
http://www.nws.noaa.gov/om/cold/wind_chill.shtml

Note that this is from a pretty old skin, and a somewhat archaic form of SKIN:Bang() is used. It will work though.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Getting "Feels Like" for Temperature to show up

Post by jsmorley »

I have to say that since weather.com's wxdata feed returns "feels like" in the feed, I have a hard time justifying this... ;-) I used to use it when I was getting the now-dead Yahoo feed, which didn't have a "feels like" data value.

Using Yahoo data of ANY KIND today is a lot like buying stock in Toys 'R Us...
Mordecai7562
Posts: 9
Joined: March 13th, 2018, 4:44 am

Re: Getting "Feels Like" for Temperature to show up

Post by Mordecai7562 »

jsmorley wrote: I have no earthly idea what these formulas are doing or what the static values represent, so don't bother asking me... ;-) I only know that they work.
I'll have to play around with that sometime, I'm sure I could make a cool weather skin with this if I ever decide to use a different wallpaper :D
Post Reply