It is currently February 20th, 2020, 4:30 pm

⭐ weather.com - Some Tools for Parsing

Our most popular Tips and Tricks from the Rainmeter Team and others
iron2000
Posts: 11
Joined: June 6th, 2011, 3:47 am

Re: ⭐ Some help with parsing weather.com

Post by iron2000 »

Is it possible to add a separate temperature unit option?

I'm thinking of making another set of measures from a separate url (switching between en-US and en-GB) just for a separate option for switching between C and F.
Just a vague idea in my mind.
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

iron2000 wrote:
January 20th, 2020, 3:36 pm
Is it possible to add a separate temperature unit option?

I'm thinking of making another set of measures from a separate url (switching between en-US and en-GB) just for a separate option for switching between C and F.
Just a vague idea in my mind.
If I understand your question correctly, there is no way I know of to send any part of the desired "units of measure" on the URL to weather.com. You have to send the language code in the URL, and then the site automatically uses the appropriate units of measure for that country / locale.

If you are simply displaying temperatures, it would not be hard at all to have some code, probably Lua, that can quickly convert between Fahrenheit and Celsius. Doing things like barometric pressure and wind speed would be a bit trickier.

https://docs.rainmeter.net/snippets/convert-temperatures/

I'm not quite sure why you would want the temperature in Celsius, but have the rest of the information using Imperial units, like miles per hour and inches of mercury and 12-hour time. However, to each his own, that is rule one in Rainmeter...
xenium
Posts: 481
Joined: January 4th, 2018, 9:52 pm

Re: ⭐ Some help with parsing weather.com

Post by xenium »

jsmorley wrote:
January 20th, 2020, 12:47 pm
I agree entirely with everything you just said.

I think with Alerts, my goal is going to be just to detect that there ARE one or more "high priority" alerts, and just allow the skin to indicate that. Then have a link that just goes to the website. I think parsing and displaying the number and contents of alerts is a bridge too far.
This can be done.
You have in my code what you need:
SevereAlert - which detects if there are alerts and activates the alert measures in the skin
PriorityAlert - which represents the highest priority alert
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

xenium wrote:
January 20th, 2020, 5:10 pm
This can be done.
You have in my code what you need:
SevereAlert - which detects if there are alerts and activates the alert measures in the skin
PriorityAlert - which represents the highest priority alert
I used the following approach for alerts:

Code: Select all

[MeasureAlerts]
Measure=String
String=[@CurrentAll]
DynamicVariables=1
IfMatch="severityCode":
IfNotMatchAction=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName ""]
IfMatch2="severityCode":4
IfMatchAction2=[!SetOption MeterAlert ImageName "4.ico"][!ShowMeter MeterAlert]
IfMatch3="severityCode":3
IfMatchAction3=[!SetOption MeterAlert ImageName "3.ico"][!ShowMeter MeterAlert]
IfMatch4="severityCode":2
IfMatchAction4=[!SetOption MeterAlert ImageName "2.ico"][!ShowMeter MeterAlert]
IfMatch5="severityCode":1
IfMatchAction5=[!SetOption MeterAlert ImageName "1.ico"][!ShowMeter MeterAlert]
It seemed the lightest and most likely to not change.
xenium
Posts: 481
Joined: January 4th, 2018, 9:52 pm

Re: ⭐ Some help with parsing weather.com

Post by xenium »

jsmorley wrote:
January 20th, 2020, 7:05 pm
I used the following approach for alerts:

Code: Select all

[MeasureAlerts]
Measure=String
String=[@CurrentAll]
DynamicVariables=1
IfMatch="severityCode":
IfNotMatchAction=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName ""]
IfMatch2="severityCode":4
IfMatchAction2=[!SetOption MeterAlert ImageName "4.ico"][!ShowMeter MeterAlert]
IfMatch3="severityCode":3
IfMatchAction3=[!SetOption MeterAlert ImageName "3.ico"][!ShowMeter MeterAlert]
IfMatch4="severityCode":2
IfMatchAction4=[!SetOption MeterAlert ImageName "2.ico"][!ShowMeter MeterAlert]
IfMatch5="severityCode":1
IfMatchAction5=[!SetOption MeterAlert ImageName "1.ico"][!ShowMeter MeterAlert]
It seemed the lightest and most likely to not change.
:thumbup:
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3763
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: ⭐ Some help with parsing weather.com

Post by eclectic-tech »

@ JSMorley Thanks for all your work on fashioning X(x)enium's code as includes. :rosegift:

I have been following the discussion here and have created my own versions (Separate: Current, Forecasts, and 36Hours measures), which are based on yours, but fashioned them to take advantage of Xenium's language setting skin from his Windows 10 Weather (Enterprise Edition). :sly:

I put together a demonstration skin that will show the values returned in the log for each include or all data, and demonstrate setting the information to several languages (thanks Xenium! :rosegift: )

I also borrowed your weather example skin to show the language change; It was easier than writing my own :oops:

Here is my WeatherData rmskin for anyone who wants to see what I have been doing.

WeatherData (english) preview
weatherdata_english.png
WeatherData (spanish) preview
weatherdata_spanish.png
Hope you don't mind my taking a slightly different route, but that's usually me :D

HISTORY
Updated Include files with corrections (Jan 23, 2020)

EDIT2:
Now All include files match the ones developed by JSMorley
The only difference is that these include a language selector skin based on Xenium's "Windows10 Weather Enterprise Edition" :rosegift:

EDIT:
Renamed all included measures by replacing 'Measure' with '@' so they should be unique when using to edit old skins. (See Tip)


.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

eclectic-tech wrote:
January 20th, 2020, 10:27 pm
@ JSMorley Thanks for all your work on fashioning X(x)enium's code as includes. :rosegift:

I have been following the discussion here and have created my own versions (Separate: Current, Forecasts, and 36Hours measures), which are based on yours, but fashioned them to take advantage of Xenium's language setting skin from his Windows 10 Weather (Enterprise Edition). :sly:

I put together a demonstration skin that will show the values returned in the log for each include or all data, and demonstrate setting the information to several languages (thanks Xenium! :rosegift: )

I also borrowed your weather example skin to show the language change; It was easier than writing my own :oops:

Hope you don't mind my taking a slightly different route, but that's usually me :D
The more the merrier!
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

Changed the @Include files to make them a bit more logical and easy to use.

Thanks for the back-and-forth with eclectic-tech!

All the measures that are brought into the skin with @Include will have a name that is prefaced with "@" Should make them easy to spot.



2.png



New .rmskin in the first post of this thread.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

Some minor renaming of the .inc files so they stand out better in your @Resource folder.

New .rmskin in the first post of this thread.
User avatar
balala
Rainmeter Sage
Posts: 9724
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ Some help with parsing weather.com

Post by balala »

jsmorley wrote:
January 20th, 2020, 3:41 pm
If I understand your question correctly, there is no way I know of to send any part of the desired "units of measure" on the URL to weather.com. You have to send the language code in the URL, and then the site automatically uses the appropriate units of measure for that country / locale.
One possible solution of the question in cause would be to manually convert the units. As far as I know you can easily get the temperature unit in which the values are returned in the skin. One single properly created Calc measure can convert the Celsius to Fahrenheit or vice-versa, Fahrenheit to Celsius. I suppose this isn't too hard to be done.