Weather Data Source
-
At the risk of going over some old ground here.....
I would like to Have a data source that I can log Current Temperature, Humidity, and wind speed for say
https://www.timeanddate.com/weather/australia/sydney
Looks like I need a http retriever?
I have read a few topics in the forum already such as https://forum.infiniteautomation.com/topic/3837/sunrise-sunset
but I must say that the whole Regex thing blows my mind.
Just wondering if anyone can assist in this with what is required to grab these parameters?
My Purpose is to check Cooling tower Water consumption in different weather conditions, and it would be good not to have a weather station at each location.
Any advise is appreciated.
Cheers!
-
Hi Pikey4,
my solution with openweathermap.org.
First step create a data source "HTTP Retriever":In the URL field you have to put the following:
Second step create some datapoints:
The api paramters:
openweather
Create a datapoint Temp (temperature):
Or city:
Or humidity:
-
Hi Pikey4,
One place to experiment with Regex is your browser's development tools. In the JavaScript Console, you can try the regex in between / / on the page, like,
/.*Humidity: .*?(\d+%).*/.exec(document.body.innerHTML)
Which will return an array if we got a match,
/.*Humidity: .*?(\d+%).*/.exec(document.body.innerHTML)[1]
It would probably take more work to grab the whole forecast and the HttpRetriever may not be the best solution if one were to go after forecast data.
So,
.*Humidity: .*?(\d+%).*
will be our regex and 1 is the capture group, for Humidity.Temperature seems a little more difficult, but we can see in a wget that it's easy to find that value relative to the word 'Now' in the same fashion, like,
.*Now.*?(\d+) °F.*
-
If you are unsure about regular expressions: regexr.com is a darned good resource and has helped me on many occasions. It also has a glossary of terms you can use in order to best 'capture' the groups of data you desire.
I use Weather Underground's API for my data (wunderground.com) as it provides a flexible API as well as forecasting.
and would suggest that but it appears some do-gooders have decided to shut the api down in two months for a more favourable pay 20x more for everything...
If I find something soon that works I'll keep you informed. Personally, I'd use an http query (namely curl) from a bash script to generate a file which could be in CSV format from an API that mango could parse into a datafile datasource. But that's just my approach. Keeps the API calls low too. -
Thanks all, This has been very helpful.