It is currently May 19th, 2019, 7:41 am

WXDataWeather

Post your work-in-progress and completed skins to share and discuss.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

WXDataWeather

jsmorley » November 18th, 2015, 5:55 pm

Edit: Updated to version 1.1, due to a little bug in the "day to night" transition stuff.
Edit: Updated to version 1.2, to use SilverAzide's new icon set.
Edit: Updated to version 1.3, to add alert icon when your location has severe weather alerts.
Edit: Updated to version 1.4, to add a tooltip with the text of any severe weather alerts
Edit: Updated to Version 2.0, to add the WXDataLocation skin to choose a city location code
Edit: Updated to Version 2.1, to make some minor changes to the skin context menu
WXDateaWeather.png
deviantART: WXDataWeather 2.1

While messing with the WXData feed for Weather.com, I decided to modify one of my existing skins to use the data. There are a couple of data elements, like "Feels Like" and "Percent Possible Precipitation" that aren't in other feeds, and the the "day" vs "night" forecasts are useful.

Grab the .rmskin from the link above and install it. Requires the latest 3.3 or later from http://rainmeter.net.

Set your weather location code and unit of measure in WXDataWeatherVars.inc.
You can search for a location code by selecting "Choose location code" from the skin context menu.

Unit of measure can also be changed by right-clicking and selecting "Change to Fahrenheit" or "Change to Celsius".

Other variables like fonts and colors can be set in GeneralVariables.inc.

Note:

This uses a WXDataWeatherRegExp.inc file, which has regular expressions for virtually every (about 180) useful data element in the 6-day Weather.com feed. It uses an approach were the the entire feed is downloaded only once, and access to it is broken up into logical "sections". You simply use the parent sections and child elements in your own skins as needed. Use a few, use them all. This approach should make it pretty simple.

WXDataWeatherRegExp.inc:

Code: Select all

; Do NOT change this file unless you are sure you know what you are doing.
; ========================================================================
[Variables]
UnitsOfMeasure=(?siU)<head>.*<locale>(.*)</locale>.*<form>(.*)</form>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*</head>
Location=(?siU)<loc id="(.*)".*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*</loc>
CurrentConditions=(?siU)<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>
CurrentBarometric=(?siU)<cc>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*</bar>
CurrentWind=(?siU)<cc>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
CurrentElements=(?siU)<cc>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*</uv>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*</moon>.*</cc>
TodayGeneral=(?siU)<dayf>.*<lsup>(.*)</lsup>.*<day d="0".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
TodayDayConditions=(?siU)<day d="0".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>.*</part>
TodayDayWind=(?siU)<day d="0".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>.*</part>
TodayDayElements=(?siU)<day d="0".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
TodayNightConditions=(?siU)<day d="0".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>.*</part>
TodayNightWind=(?siU)<day d="0".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>.*</part>
TodayNightElements=(?siU)<day d="0".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day1General=(?siU)<day d="1".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
Day1DayConditions=(?siU)<day d="1".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day1DayWind=(?siU)<day d="1".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day1DayElements=(?siU)<day d="1".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day1NightConditions=(?siU)<day d="1".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day1NightWind=(?siU)<day d="1".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day1NightElements=(?siU)<day d="1".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day2General=(?siU)<day d="2".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
Day2DayConditions=(?siU)<day d="2".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day2DayWind=(?siU)<day d="2".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day2DayElements=(?siU)<day d="2".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day2NightConditions=(?siU)<day d="2".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day2NightWind=(?siU)<day d="2".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day2NightElements=(?siU)<day d="2".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day3General=(?siU)<day d="3".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
Day3DayConditions=(?siU)<day d="3".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day3DayWind=(?siU)<day d="3".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day3DayElements=(?siU)<day d="3".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day3NightConditions=(?siU)<day d="3".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day3NightWind=(?siU)<day d="3".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day3NightElements=(?siU)<day d="3".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day4General=(?siU)<day d="4".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
Day4DayConditions=(?siU)<day d="4".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day4DayWind=(?siU)<day d="4".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day4DayElements=(?siU)<day d="4".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day4NightConditions=(?siU)<day d="4".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day4NightWind=(?siU)<day d="4".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day4NightElements=(?siU)<day d="4".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day5General=(?siU)<day d="5".*t="(.*)".*dt="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
Day5DayConditions=(?siU)<day d="5".*<part p="d">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day5DayWind=(?siU)<day d="5".*<part p="d">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day5DayElements=(?siU)<day d="5".*<part p="d">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
Day5NightConditions=(?siU)<day d="5".*<part p="n">.*<icon>(.*)</icon>.*<t>(.*)</t>
Day5NightWind=(?siU)<day d="5".*<part p="n">.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*</wind>
Day5NightElements=(?siU)<day d="5".*<part p="n">.*<bt>(.*)</bt>.*<ppcp>(.*)</ppcp>.*<hmid>(.*)</hmid>.*</part>
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Posts: 555
Joined: March 23rd, 2015, 5:26 pm

Re: WXDataWeather

SilverAzide » November 19th, 2015, 12:51 am

These RegExp's are great, but I have a question for you.

The weather.com feed sometimes adds a "severe weather alert" between the <loc></loc> and <cc></cc> tags. It looks something like this:

Code: Select all

...
</loc>
<swa>
  <a id="642827" uc="2">
    <t>Flash Flood Watch until Sun Jun 28 2015 02:00 AM</t> 
    <l>http://www.weather.com/weather/alerts/localalerts/12345?phenomena=FF&significance=A&areaid=AAA123&office=KLWX&etn=0003</l> 
  </a>
</swa>
<cc>
...
I cannot figure out the regexp needed to grab the message and link AND (this is the important part) NOT throw a "RegExp matching error (-1)" message in the debug log when the <swa></swa> section is not present. Returning an empty string would be nice in cases of no alert.

If you know of a way to do this, it would be super helpful to add this regexp to your handy include file.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WXDataWeather

jsmorley » November 19th, 2015, 1:44 am

SilverAzide wrote:These RegExp's are great, but I have a question for you.

The weather.com feed sometimes adds a "severe weather alert" between the <loc></loc> and <cc></cc> tags. It looks something like this:

Code: Select all

...
</loc>
<swa>
  <a id="642827" uc="2">
    <t>Flash Flood Watch until Sun Jun 28 2015 02:00 AM</t> 
    <l>http://www.weather.com/weather/alerts/localalerts/12345?phenomena=FF&significance=A&areaid=AAA123&office=KLWX&etn=0003</l> 
  </a>
</swa>
<cc>
...
I cannot figure out the regexp needed to grab the message and link AND (this is the important part) NOT throw a "RegExp matching error (-1)" message in the debug log when the <swa></swa> section is not present. Returning an empty string would be nice in cases of no alert.

If you know of a way to do this, it would be super helpful to add this regexp to your handy include file.
There is really no practical way to do this with WebParser. You can use a lookahead assertion to avoid regular expression matching errors easily enough, but that won't stop what also will happen, which is a "Not enough substrings" error on the child measure(s). Really nothing will stop that.

If this was like the "day" forecast icon, that they turn off after some time in the afternoon by setting <icon></icon> with no value between, it would be fine. (.*) means "zero or more" and so you get no matching error and there is still a substring, even though it will be an empty string. With this <swa>...</swa> stuff, when there is no alert the entire <swa> is just missing, so you get a matching error unless you use a lookahead, and then there is no substring created. So you can't really beat it with regular expression / WebParser.

About the only thing I can think of is to make sure you have a parent measure that uses the RegExp=#Location# variable so you have a measure that has all the <loc>...</loc> data in it. Then have a Lua script that reads that measure, parses it looking for the <swa>...</swa> information, and takes whatever action you want. Set some meter values, unhide an image, whatever you need.
User avatar
SilverAzide
Posts: 555
Joined: March 23rd, 2015, 5:26 pm

Re: WXDataWeather

SilverAzide » November 19th, 2015, 5:42 pm

To anyone who may be interested:

I have created a variant set of icons for use with weather.com that are based on the icons in JSMorley's weather skins. The original set of icons were intended for Yahoo's weather feed, but this set is intended for the weather.com feed. Weather.com icon codes seem to be slightly different, especially for codes greater than 36 where there are more day/night-specific icons. Other specific examples of differences include codes 39 (Yahoo = "scattered thunderstorms", TWC = "AM rain") and 45 (Yahoo = "thundershowers", TWC = "PM rain"). I've also made very minor tweaks to distinguish between "drizzle" and "light showers", "flurries" and "light snow", "sunny" and "fair", etc.

Another observation for anyone creating weather.com skins, is that weather.com does not use code 3200 to indicate "N/A" conditions; instead, it just uses a blank code (empty string).

You can get the icon set here on DeviantArt: http://sta.sh/0xthn1jrp4v.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WXDataWeather

jsmorley » November 19th, 2015, 6:29 pm

SilverAzide wrote:To anyone who may be interested:

I have created a variant set of icons for use with weather.com that are based on the icons in JSMorley's weather skins. The original set of icons were intended for Yahoo's weather feed, but this set is intended for the weather.com feed. Weather.com icon codes seem to be slightly different, especially for codes greater than 36 where there are more day/night-specific icons. Other specific examples of differences include codes 39 (Yahoo = "scattered thunderstorms", TWC = "AM rain") and 45 (Yahoo = "thundershowers", TWC = "PM rain"). I've also made very minor tweaks to distinguish between "drizzle" and "light showers", "flurries" and "light snow", "sunny" and "fair", etc.

Another observation for anyone creating weather.com skins, is that weather.com does not use code 3200 to indicate "N/A" conditions; instead, it just uses a blank code (empty string).

You can get the icon set here on DeviantArt: http://sta.sh/0xthn1jrp4v.
Very nice. I have changed to those icons on the deviantART link in the first post. Thanks.
User avatar
SilverAzide
Posts: 555
Joined: March 23rd, 2015, 5:26 pm

Re: WXDataWeather

SilverAzide » November 22nd, 2015, 3:50 am

:thumbup:
Image
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WXDataWeather

jsmorley » November 22nd, 2015, 1:21 pm

SilverAzide wrote::thumbup:
Image
Yeah, I looked at parsing the alerts themselves, but found two things. First, there can easily be multiple alerts at any given time. In fact, a lot of "weather events" by the nature of them involve multiple different alert "types" like Heavy Rain and High Winds and Flooding. So it gets involved and complicated to parse them into some "zero to unlimited" number of entries that can usefully be displayed in Rainmeter. I don't think you want to be warned about the "wind" alert, and then have the "flooding" alert you didn't see cause you to become a face on a milk carton. Second, those "links" that it returns are almost always bogus and end up on some "404" page in Weather.com. I don't think they have kept those links up with the actual site technology since they are not that interested in these feeds anymore anyway.

So I just set an alert icon if there are any alerts, and when you click on the conditions icon you go to the site as always, where naturally the alerts are prominently shown. The alert icon basically means "go to the site, there is something you need to know".
User avatar
SilverAzide
Posts: 555
Joined: March 23rd, 2015, 5:26 pm

Re: WXDataWeather

SilverAzide » November 22nd, 2015, 4:21 pm

Yep, I found out about those bogus links too. However, it turns out you can fix them on the fly if you wanted to get them to work. Something like:

Code: Select all

[MeasureAlertLink]
Measure=Plugin
Plugin=WebParser
Url=[MeasureAlerts]
DecodeCharacterReference=1
Substitute="localalerts/":"localalerts/l/"
Basically, the link they supply is missing the "l/"... today anyway, next week it could be something else. But you are right about the multiple alerts. I think your approach works well and gets the point across, and has the side benefit of not spewing out error messages in the logs about regexp parsing issues.

Image
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WXDataWeather

jsmorley » November 22nd, 2015, 5:19 pm

SilverAzide wrote:Yep, I found out about those bogus links too. However, it turns out you can fix them on the fly if you wanted to get them to work. Something like:

Code: Select all

[MeasureAlertLink]
Measure=Plugin
Plugin=WebParser
Url=[MeasureAlerts]
DecodeCharacterReference=1
Substitute="localalerts/":"localalerts/l/"
Basically, the link they supply is missing the "l/"... today anyway, next week it could be something else. But you are right about the multiple alerts. I think your approach works well and gets the point across, and has the side benefit of not spewing out error messages in the logs about regexp parsing issues.
It's a bit more than the missing /l/ subfolder. There is also the fact that it is encoded with "&" HTML replacement codes for the "&" character, which makes no sense at all in a URL encoding world, (you don't need to encode "&", and it would be "%26" if you did) and the missing "event id" at the end. All of it can be managed, but I concluded it was more trouble than it was worth.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WXDataWeather

jsmorley » November 24th, 2015, 3:52 pm

I went ahead and parsed the text for any <swa> Severe Weather Alerts in the feed. I have set them as a ToolTip on the Alert icon if present.
1.jpg
Links in the first post of the thread.
You do not have the required permissions to view the files attached to this post.