It is currently December 6th, 2022, 2:12 pm

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
SilverAzide
Rainmeter Sage
Posts: 2178
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by SilverAzide »

zivallh wrote: October 8th, 2022, 7:33 pm Is it possible to make something like this for "roundline" meter for high and low temp since the high temp doesn't stay and have to use @CurrentTemperatureMaxSince7AM
Your logic appears to assume that the night temperature is never going to be higher than the day or "max since 7AM" temperature. This is not always true; there are plenty of times when the night can be warmer than the day (like when a warm front moves through during evening hours).
Gadgets Wiki GitHub More Gadgets...
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

I'm using this skin to make a "Roundline" of the temperature not about logical or not :)

Something like this

Image

My question was here because when I use the variable it disappears, wondering why it's disappearing
because the high temp of the day doesn't stay so I have to use @CurrentTemperatureMaxSince7AM

Code: Select all

MaxValue=#MaxValue#

IfMatchAction=[!SetOption MeterTodayHighLow MeasureName2 "@CurrentTemperatureMaxSince7AM"][!WriteKeyValue Variables MaxValue "[@CurrentTemperatureMaxSince7AM]"]
IfNotMatchAction=[!SetOption MeterTodayHighLow MeasureName2 "@ForecastTodayDayTemperature"][!WriteKeyValue Variables MaxValue "[@ForecastTodayHighTemperature]"]
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

I figure it out

Max Value has to be like this MaxValue=[#MaxValue#]
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by balala »

zivallh wrote: October 9th, 2022, 5:49 pm Max Value has to be like this MaxValue=[#MaxValue#]
I doubt this could work. #MaxValue# is the value of the MaxValue variable, which is the value returned either by the [@CurrentTemperatureMaxSince7AM] or the [@ForecastTodayHighTemperature] measure (as written by the !WriteKeyValue bangs of the IfMatchAction or IfNotMatchAction options). These probably are numbers. By including something into brackets, you tell Rainmeter that thing is a measure. Accordingly [#MaxValue#] is treated by Rainmeter as the measure which name is the value of the #MaxValue# variable (for instance [30], but this is just an example). Are you sure there are measures for each value which can be get with the #MaxValue# variable (or in fact with the [@CurrentTemperatureMaxSince7AM] and [@ForecastTodayHighTemperature] measures)? Doesn't really make sense...
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

I'm not sure, but it worked

Here's the full skin code, if you can check if it's right.

There are 3 measures from jsmorley for the day temp

[@ForecastTodayDayTemperature]
[@ForecastTodayHighTemperature]
[@CurrentTemperatureMaxSince7AM]

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
MouseScrollUpAction=[!SetVariable Scale "([#Scale]+0.05)"][!WriteKeyValue Variables Scale "([#Scale]+0.05)"][!UpdateMeter *][!Redraw] 
MouseScrollDownAction=[!SetVariable Scale "([#Scale]-0.05 < 0.2 ? 0.2 : [#Scale]-0.05)"][!WriteKeyValue Variables Scale "([#Scale]-0.05 < 0.2 ? 0.2 : [#Scale]-0.05)"][!UpdateMeter *][!Redraw]

[Metadata]
Name=
Author=
Version=
License=

[Variables]
@Include=#@#WeatherComJSONVariables.inc
@Include2=#@#WeatherComJSONMeasures.inc

Scale=1.55

FStyle=Normal
FStyle2=Normal

Color=255,255,255
NormalColor=0,0,0,25

White=255,255,255
LightBlue=0,255,255
Blue=0,125,225
Orange=255,135,0
LightRed=200,35,0
Red=255,0,0

MaxValue=@CurrentTemperatureMaxSince7AM


[@CurrentTemperature]
Measure=WebParser
URL=[@CurrentConditionsParent]
StringIndex=11
RegExpSubstitute=1
Substitute=#CommonSubstitute#

IfCondition=([@CurrentTemperature] < 0)
IfTrueAction=[!SetOption MeterTempRound LineColor "#White#"]

IfCondition2=([@CurrentTemperature] >= 0) && ([@CurrentTemperature] <= 11)
IfTrueAction2=[!SetOption MeterTempRound LineColor "#LightBlue#"]

IfCondition3=([@CurrentTemperature] >= 12) && ([@CurrentTemperature] <= 20)
IfTrueAction3=[!SetOption MeterTempRound LineColor "#Blue#"]

IfCondition4=([@CurrentTemperature] >= 21) && ([@CurrentTemperature] <= 28)
IfTrueAction4=[!SetOption MeterTempRound LineColor "#Orange#"]

IfCondition5=([@CurrentTemperature] >= 29) && ([@CurrentTemperature] <= 35)
IfTrueAction5=[!SetOption MeterTempRound LineColor "#LightRed#"]

IfCondition6=([@CurrentTemperature] >= 36)
IfTrueAction6=[!SetOption MeterTempRound LineColor "#Red#"]

DynamicVariables=1

;--------------------------------------------------- Low Tonight

[MeasureNewForecastTodayDayTemperature]
Measure=String
Group=Weather
String=[@ForecastTodayDayTemperature]
IfMatch=^$
IfMatchAction=[!SetOption MeterTodayHighLow Text "Low Tonight %1°"]
IfNotMatchAction=[!SetOption MeterTodayHighLow Text "%1° | %2°"]
DynamicVariables=1
Disabled=0

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

[MeasureToggleAtNight]
Measure=String
Group=Weather
String=[@ForecastTodayDayTemperature]
DynamicVariables=1
IfMatch=^$
IfMatchAction=[!SetOption MeterTodayHighLow MeasureName2 "@CurrentTemperatureMaxSince7AM"][!WriteKeyValue Variables MaxValue "@CurrentTemperatureMaxSince7AM"][!!UpdateMeasure "MeasureTempCircle"][!UpdateMeter *][!Redraw]
IfNotMatchAction=[!SetOption MeterTodayHighLow MeasureName2 "@ForecastTodayDayTemperature"][!WriteKeyValue Variables MaxValue "@ForecastTodayHighTemperature"][!!UpdateMeasure "MeasureTempCircle"][!UpdateMeter *][!Redraw]

[MeasureTempCircle]
Measure=Calc
Formula=@CurrentTemperature
MinValue=[@ForecastTodayLowTemperature]
;[@ForecastTodayNightTemperature]
;[@ForecastTodayLowTemperature]
MaxValue=[#MaxValue#]
;#MaxValue#
;[@ForecastTodayDayTemperature]
;[@ForecastTodayHighTemperature]
;[@CurrentTemperatureMaxSince7AM]
DynamicVariables=1

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

[Background]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=(140*#Scale#)
H=(140*#Scale#)
DynamicVariables=1

[MeterBG]
Meter=Roundline
MeasureName=MeasureBG
X=(70*#Scale#)
Y=(70*#Scale#)
;LineWidth=(17*#Scale#)
LineLength=0
LineStart=(70*#Scale#)
LineColor=#NormalColor#
Solid=1
AntiAlias=1
DynamicVariables=1

[MeterRound]
Meter=Roundline
X=(70*#Scale#)
Y=(70*#Scale#)
Autoscale=1
StartAngle=(Rad(90))
;LineWidth=(17*#Scale#)
LineLength=(70*#Scale#)
LineStart=(69*#Scale#)
LineColor=#Color#,100
Solid=1
AntiAlias=1
DynamicVariables=1

[MeterTempRound]
Meter=Roundline
MeasureName=MeasureTempCircle
X=(70*#Scale#)
Y=(70*#Scale#)
Autoscale=1
StartAngle=(Rad(90))
;LineWidth=(17*#Scale#)
LineLength=(70*#Scale#)
LineStart=(69*#Scale#)
LineColor=#Color#
Solid=1
AntiAlias=1
DynamicVariables=1

[MeterCondition]
Meter=String
Measurename=@CurrentConditions
FontFace=San Francisco Text
FontSize=(8*#Scale#)
FontColor=#ColorCond#
Antialias=1
Stringcase=Upper
StringAlign=Center
Clipstring=1
W=(90*#Scale#)
H=(32*#Scale#)
X=(70*#Scale#)
Y=(25*#Scale#)r
DynamicVariables=1

[MeterTemperature]
MeasureName=@CurrentTemperature
Meter=String
FontFace=NimbusSanPULtLig
FontSize=(44*#Scale#)
FontColor=#Color#
Antialias=1
StringAlign=Center
Text="%1°"
;°˚
X=(70*#Scale#)
Y=(35*#Scale#)
DynamicVariables=1

[MeterTodayHighLow]
MeasureName=@ForecastTodayLowTemperature
MeasureName2=@ForecastTodayHighTemperature
Meter=String
FontFace=San Francisco Text
FontSize=(5*#Scale#)
FontColor=#Color#
Antialias=1
Stringcase=Upper
StringAlign=Center
Text="%1° | %2°"
;°˚
X=(70*#Scale#)
Y=(115*#Scale#)
DynamicVariables=1

User avatar
SilverAzide
Rainmeter Sage
Posts: 2178
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by SilverAzide »

zivallh wrote: October 10th, 2022, 3:55 pm I'm not sure, but it worked

Here's the full skin code, if you can check if it's right.

There are 3 measures from jsmorley for the day temp
Well... yes, it worked, but perhaps not for the reason you think. balala is correct to have his doubts.

Your variable MaxValue is not the value of the measure, it is the name of the measure. That is why you need both the square brackets and the # signs. MaxValue is literally the string "@CurrentTemperatureMaxSince7AM", it is not the temperature value.

Your method does work, obviously, but there is a better way to do this if you care. You can "escape" the measure. Balala might be able to tell you how if you (and he) are interested.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 14766
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by balala »

SilverAzide wrote: October 10th, 2022, 4:58 pm Your variable MaxValue is not the value of the measure, it is the name of the measure. That is why you need both the square brackets and the # signs. MaxValue is literally the string "@CurrentTemperatureMaxSince7AM", it is not the temperature value.
Right, however note that there is a difference between how the code have been posted by zivallh in his two posts. He used brackets in his first post, but didn't when posted the whole code.
The MaxValue is the value of the appropriate measure in first case, but is the name of measure in second case. Important difference...
zivallh wrote: October 10th, 2022, 3:55 pm I'm not sure, but it worked

Here's the full skin code, if you can check if it's right.
See above my reply to SilverAzide. I suppose the second code is the one which works. If this is right, the first code can't work.
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

Yeah I know without brackets it won’t work, I figured that later, then I changed the code and posted, do you guys have better option we can do?
User avatar
SilverAzide
Rainmeter Sage
Posts: 2178
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by SilverAzide »

zivallh wrote: October 10th, 2022, 7:27 pm Yeah I know without brackets it won’t work, I figured that later, then I changed the code and posted, do you guys have better option we can do?
You could escape the measure names, like so:

Code: Select all

MaxValue="[*@CurrentTemperatureMaxSince7AM*]"

; etc.

[MeasureToggleAtNight]
;...
IfMatchAction=...[!SetVariable MaxValue "[*@CurrentTemperatureMaxSince7AM*]"]...
IfNotMatchAction=...[!SetVariable MaxValue "[*@ForecastTodayHighTemperature*]"]...

; etc.
Your use of !WriteKeyValue is not correct, you actually want to use !SetVariable. Now instead of using [#MaxValue#] you can just use #MaxValue#.
Gadgets Wiki GitHub More Gadgets...
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

Thank you guys SilverAzide and balala!! :thumbup: