Ok, will try.
I use accuweather because the minutecast live’ info is eerily accurate around my house (it really is crazy how spot on it is around London!)
For now, the scrape is literally an exec binding job like this:
/usr/bin/wget -U Mozilla/5.0 -q www.accuweather.com/en/gb/london/w1u-1/minute-weather-forecast/53870_pc -O -
The Mozilla header is because my request started getting denied without that. I try not to poll the update too frequently, I’m downloading the full web page each time.
They do have an API… but I’m too cheap to pay…
With a simple regex transform as follows:
REGEX(..div.class…mc.summary…[^<]
([\w| ]).) - to extract the strong that shows what the current short term forecast is
The output is bound to an item which I track to run a rule.
The rules parses the text field, and makes decisions any time the value changes:(with a lock, to prevent too many updates within a certain period and a check to make sure I only get alerted during certain hours… don’t wake me
I’m on a phone right now, so fetching my poorly written rule is painful, but it’s just some if statements contains regex matches like:
BAD WEATHER NOW:
transform(“REGEX”, “(?=.?\brain|Rain|snow|Snow\b)(?=.?\b(ending|least|break|continue)\b)[^\t]+”, GetRainForecast_Output.state.toString) !== null)
//BAD WEATHER DUE IN UNDER 10 MINUTES
(transform(“REGEX”, ‘(?=.?\b([0-9])\b)(?=.?\brain|Rain|snow|Snow\b)(?=.*?\b(starting)\b)[^\t]+’, GetRainForecast_Output.state.toString) !== null)
//MORE THAN 9 MINUTES AWAY
(transform(“REGEX”, “(?=.?\brain|Rain|snow|Snow\b)(?=.?\b(starting)\b)[^\t]+”, GetRainForecast_Output.state.toString) !== null)
Also I have a check for ‘no precipitation’
And finally one if none of the above lookups are met, triggering an alert that a non standard value appeared in the output - so I can amend the regex lookups.
As you can see, it’s pretty crappy old poorly written regex (I was struggling with getting my head around the openhab regex transform, so didn’t actually focus on the regex itself)
I’ll post it properly when I have time