It is currently March 28th, 2024, 1:38 pm

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
Yincognito
Rainmeter Sage
Posts: 7021
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

leofender wrote: November 28th, 2021, 3:16 pmAre the alerts settings on the skin correct or is it a Weather.com bug?
In short, yes, the alert settings in the skin are "correct", and it's not a Weather.com bug. Take a look at this (I replicated your approximate location around Valencia, Spain):
Weather.com Alerts.jpg
You can see the skin at the top right corner, the skin code from the Weather.com.ini file at the top and the Rainmeter log at the bottom of the image. The measure that "extracts" the alert from Weather.com exists and works out fine as you can see in the log (i.e. @Alert1Text, @Alert2Text and so on), it's just that the skin intentionally doesn't display "minor" alerts like these, aka alerts having a severityCode of 4, as you can see by reading the line I selected from the skin code comments.

Bottom line is, while these minor alerts aren't normally being displayed in the skin, you can easily add them by either adjusting the IfMatch/IfMatchAction options from the [MeasureAlerts] measure accordingly (basically just make the IfMatchAction2=... option that corresponds to the severity code of 4 to look like the similar options that show meters at severity codes less than 4), or just make some meter of your own and use MeasureName=@Alert1Text or something along these lines to display those alerts as well in other places of the skin.

Even more to the point, all you have to do is comment (add a ; at the start of the line) the IfMatchAction2=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName "4.png"] line and uncomment (remove the ; at the start of the line) the IfMatchAction2=[!SetOption MeterAlert ImageName "4.png"][!ShowMeter MeterAlert] line - these lines and the measure containing them are visible in the image that I attached above, by the way.
leofender
Posts: 2
Joined: November 28th, 2021, 2:40 pm

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by leofender »

Yincognito wrote: November 28th, 2021, 7:34 pm In short, yes, the alert settings in the skin are "correct", and it's not a Weather.com bug. Take a look at this (I replicated your approximate location around Valencia, Spain):
Weather.com Alerts.jpg
You can see the skin at the top right corner, the skin code from the Weather.com.ini file at the top and the Rainmeter log at the bottom of the image. The measure that "extracts" the alert from Weather.com exists and works out fine as you can see in the log (i.e. @Alert1Text, @Alert2Text and so on), it's just that the skin intentionally doesn't display "minor" alerts like these, aka alerts having a severityCode of 4, as you can see by reading the line I selected from the skin code comments.

Bottom line is, while these minor alerts aren't normally being displayed in the skin, you can easily add them by either adjusting the IfMatch/IfMatchAction options from the [MeasureAlerts] measure accordingly (basically just make the IfMatchAction2=... option that corresponds to the severity code of 4 to look like the similar options that show meters at severity codes less than 4), or just make some meter of your own and use MeasureName=@Alert1Text or something along these lines to display those alerts as well in other places of the skin.

Even more to the point, all you have to do is comment (add a ; at the start of the line) the IfMatchAction2=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName "4.png"] line and uncomment (remove the ; at the start of the line) the IfMatchAction2=[!SetOption MeterAlert ImageName "4.png"][!ShowMeter MeterAlert] line - these lines and the measure containing them are visible in the image that I attached above, by the way.
OK thank you.
I more or less understand that, but I still don't understand the severity codes or their colors.
Weather.com:
Orange symbol ... moderate risk or minor risk?

Image

Weather.com, in this case, takes the data from Meteoalarm.org whose symbology is the following:

Meteoalarm provides the most relevant information to be prepared for an extreme or exceptional weather situation that may occur anywhere in Europe. Through pictograms and color-coded maps of Europe that allow you to obtain at a glance a map of adverse weather warnings in the next 24 and 48 hours throughout Europe.

The color code of the weather warnings is as follows:

White: missing or insufficient data.

Green: No special attention is required with regard to weather conditions.

Yellow: Weather with potential hazard. Predicted phenomena are not uncommon, but attention must be paid if activities exposed to meteorological hazards are practiced. It is recommended to stay informed about the expected weather conditions and to be aware of any avoidable risks.

Orange: Weather is dangerous. Unusual weather events have been forecast and accidents or property damage are likely.

Red: The weather is very dangerous. The forecast meteorological phenomena are exceptionally intense, with great risks of material and personal damage. Extreme precautions must be taken and kept fully informed about expected weather conditions and their risks. The orders and recommendations of the authorities must be followed in all circumstances.


Image

That is why I say that I do not understand the criteria of Wheater.com when qualifying as "minor" a phenomenon that in Meteolarm, the website from which they acquire the data, qualifies as "severe" (orange) or "moderate" (yellow)

:???:

Greetings.
User avatar
Yincognito
Rainmeter Sage
Posts: 7021
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

leofender wrote: November 28th, 2021, 10:13 pmThat is why I say that I do not understand the criteria of Wheater.com when qualifying as "minor" a phenomenon that in Meteolarm, the website from which they acquire the data, qualifies as "severe" (orange) or "moderate" (yellow)
Well, to be fair, in this case, this particular event actually qualifies as moderate to low (aka yellow + white) according to Meteoalarm, if looking at the exact place where Valencia (and Gandia) is:
Gandia Valencia.jpg
That means the event is indeed not "severe", just like the textual source data you quoted earlier (i.e. severityCode:4). Now, on the colors themselves, who knows? Maybe a color means something else on Weather.com than on Meteoalarm, maybe Weather.com's "standard" color for alarms is orange, maybe they set similar colors for different severity events to panic and keep users visiting the site as a marketing strategy, etc - there can be many explanations. But again, as I said, the source page's severityCode actually matches the color in Meteoalarm, so apart from visuals, things appear to be correct. And if we talk about Weather.com visuals, after all, who cares? You're gonna display different icons and such in the skin, it's not like you take the icon from Weather.com in this case, right? :confused:

Anyway, that being said, I've also noticed the amount of "alerts" on Weather.com, and this is partly why I don't bother with weather alerts in my weather skin - I just take a field called qualifier or qualifierphrase instead of the standard alerts, it's much easier (in the code) and less "dramatic" (in appearance), if you know what I mean...

Maybe someone else will come up with a more precise explanation regarding those alarm colors. Me, I can just speculate on this, as you could see, because I'm simply not familiar enough with and I'm not using them. :D
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by SilverAzide »

leofender wrote: November 28th, 2021, 10:13 pm That is why I say that I do not understand the criteria of Wheater.com when qualifying as "minor" a phenomenon that in Meteolarm, the website from which they acquire the data, qualifies as "severe" (orange) or "moderate" (yellow)

:???:
As best as I can determine from just looking at TWC's website and how they display their data, it appears the weather codes are something like this:

Code: Select all

severityCode = 5, severity = Unknown
severityCode = 4, severity = Minor
severityCode = 3, severity = Moderate
severityCode = 2, severity = Severe
severityCode = 1, severity = Extreme
The colors seem to be red for 1/2, orange for 3, and yellow-ish for 4... but sometimes not.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

I think on the website "minor", which is severity 4, is shown as "yellow"?


1.png

2.png


As noted, I don't react to severity 4 in the skin, as there are pretty much always one or more of those. I live very near the Potomac River, and you can pretty much count on a "small craft advisory" every day. Since I don't plan on putting a dingy into the Potomac today, I really just don't care.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by SilverAzide »

The part I haven't figured out is their logic with the red/orange alerts. It's almost as if they take into account the times. Like, if there are two alerts, one severe and one extreme, it will show orange/severe instead of red/extreme if the extreme alert is not happening yet. They definitely do not display or rank the most-severe alert first, their ranking method is something else I haven't been able to identify.
User avatar
Yincognito
Rainmeter Sage
Posts: 7021
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

jsmorley wrote: November 29th, 2021, 1:30 pmAs noted, I don't react to severity 4 in the skin, as there are pretty much always one or more of those. I live very near the Potomac River, and you can pretty much count on a "small craft advisory" every day. Since I don't plan on putting a dingy into the Potomac today, I really just don't care.
LOL. Exactly my point, there seem to be a ton of "alerts" for every little wind gust out there, and while these might matter for professionals in various fields, for someone just interested in the general weather they can be too much. As a side note, what I like about the "qualifier" field is that it only mentions something when the event is actually more serious. On the downside, if I remember correctly, this is only available for forecasts, but then, the current day is included there as well, so no practical loss there.
SilverAzide wrote: November 29th, 2021, 1:41 pm The part I haven't figured out is their logic with the red/orange alerts. It's almost as if they take into account the times. Like, if there are two alerts, one severe and one extreme, it will show orange/severe instead of red/extreme if the extreme alert is not happening yet. They definitely do not display or rank the most-severe alert first, their ranking method is something else I haven't been able to identify.
Yeah, I guess that's the whole point made by the OP, i.e. the logic behind the colors. Thinking about it, maybe one could find out what that logic is by examining the source page - if it's not hidden behind some Javasxcript, the color / image chosen to represent the alert should be clearly visible. EDIT: after checking out, it appears it's not so obvious, after all - this is what the page source looks like in the said area (a "special weather statement" for Atlanta, GA):

Code: Select all

                                    <a
                                        class="AlertHeadline--AlertHeadline--1rQGw CurrentConditions--alertPadding--2Ly48 AlertHeadline--light--3qPxX Button--default--3zkvy"
                                        href="/weather/alerts/localalerts/l/8f5c8f0c5dd7699966caf7dcb4880c3847a86092521a187546b808f3023b9120?phenomena=TSL&amp;significance=S&amp;areaid=GAZ033&amp;office=KFFC&amp;etn=0000"
                                        target="_self"
                                    >
                                        <svg
                                            set="heads-up"
                                            name="breaking-news-severe"
                                            theme="light"
                                            class="AlertHeadline--alertIcon--1rOnI alerts--alert-2-color--3swQb Icon--icon--3wCKh Icon--lightTheme--3NMAI"
                                            data-testid="Icon"
                                            aria-hidden="true"
                                            role="img"
                                            viewBox="0 0 24 24"
                                        >
                                            <title>Severe Breaking News</title>
                                            <circle fill="currentColor" transform="matrix(-1 0 0 1 24 0)" cx="12" cy="12" r="12"></circle>
                                            <path fill="#FFF" d="M12 19a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm-.75-5h1.5S14 7.77 14 7a2 2 0 10-4 0c0 1.105 1.25 7 1.25 7z"></path>
                                        </svg>
                                        <h2 class="AlertHeadline--alertText--HuLAu">Special Weather Statement</h2>
                                        <svg set="ui" name="caret-right" theme="light" class="AlertHeadline--arrowIcon--2HN5h Icon--icon--3wCKh Icon--lightTheme--3NMAI" data-testid="Icon" aria-hidden="true" role="img" viewBox="0 0 24 24">
                                            <title>Arrow Right</title>
                                            <path d="M15.086 12L7.793 4.707a1 1 0 1 1 1.414-1.414l8 8a1 1 0 0 1 0 1.414l-8 8a1 1 0 1 1-1.414-1.414L15.086 12z"></path>
                                        </svg>
                                    </a>
Not too helpful, right? There is also the thing that the alt title in the icon always says "severe breaking news" even though stuff is not severe at all, it makes things even more confusing. Luckily, jsmorley found out a yellow alert, because otherwise the vast majority seem to be orange... :???:

P.S. Other things might be hidden in the CSS for the page, but I haven't got the patience to check the many entries there...
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by SilverAzide »

Yincognito wrote: November 29th, 2021, 2:42 pm Not too helpful, right? There is also the thing that the alt title in the icon always says "severe breaking news" even though stuff is not severe at all, it makes things even more confusing. Luckily, jsmorley found out a yellow alert, because otherwise the vast majority seem to be orange... :???:
There's a reference in the HTML to "significance" that plays into it somehow (the API has a reference to "urgency"). Like if you have a severe smog alert (low significance) and a moderate storm alert (high significance), the moderate alert "outranks" it on TWC's site. But I've seen the opposite too, so I've given up trying to figure out the system. I just grab the most severe one and display the icon for that (which might not be the first in a list of alerts)... seems to be close enough.
User avatar
Yincognito
Rainmeter Sage
Posts: 7021
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

SilverAzide wrote: November 29th, 2021, 3:14 pm There's a reference in the HTML to "significance" that plays into it somehow (the API has a reference to "urgency"). Like if you have a severe smog alert (low significance) and a moderate storm alert (high significance), the moderate alert "outranks" it on TWC's site. But I've seen the opposite too, so I've given up trying to figure out the system. I just grab the most severe one and display the icon for that (which might not be the first in a list of alerts)... seems to be close enough.
Yep, after all, this is what is generally of concern for an user: how worse could the weather be. The rest is just less important if you're already prepared for the worst. Or something like that, anyway.
User avatar
zivallh
Posts: 38
Joined: October 16th, 2019, 2:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by zivallh »

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

Code: Select all

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


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

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