is there a driver (not extension) for http get of json data ?

119 views
Skip to first unread message

Vince Skahan

unread,
Feb 25, 2020, 3:23:58 PM2/25/20
to weewx-development
I'm working with a user who is looking to get weewx running vs. his Davis WeatherLink IP device.   There's no driver for that currently, although there's an issue open on it in the weewx repo.

In looking at the Davis docs I see we can query current conditions via a simple web get, and the current observations come back in JSON format.   That looks to me notionally like what the PurpleAir extension does, just with different JSON data to parse into weewx db elements of course.   Looks doable.

Before going too far down that path, I was wondering if there a generic 'query a URL that returns JSON' driver to start with ?

Secondly, if I take the PA extension, which is an extension (not a driver), is it a big deal to convert that to a driver instead ?   Any guidance/examples there ?

Thanks.




mwall

unread,
Feb 25, 2020, 3:38:57 PM2/25/20
to weewx-development


On Tuesday, February 25, 2020 at 3:23:58 PM UTC-5, Vince Skahan wrote:
Before going too far down that path, I was wondering if there a generic 'query a URL that returns JSON' driver to start with ?

someone should implement that :)

in fact, it would be nice if that were a base class in weewx core that other drivers could use.  when i started weewx-interceptor i thought it would be that easy.  but it turns out that each hardware vendor does things just a little bit different than any other.

doing the http GET, receiving JSON data, parsing JSON data, and even doing it on a separate thread so you don't block the weewx engine - those are all pretty easy with python.

mapping the JSON fields to database fields, and sorting out the units - those are still squarely in the land of weewx.  the sensor_map and sensor_map_extensions patterns seem to work fairly well.

 
Secondly, if I take the PA extension, which is an extension (not a driver), is it a big deal to convert that to a driver instead ?   Any guidance/examples there ?

the weewx-maxbotix and weewx-cmon extensions are both examples of dual driver/service behavior.  you might want to look at weewx-maxbotix first, since weewx-cmon has a lot of platform-specific stuff in it.

the basic idea is that you do a 'device' class that implements the methods required to talk to the hardware, then you include that in either a weewx driver or a weewx service.  i put the code for all of it into a single file, along with any special schema that might be required.  and of course a testing stub that uses the 'device' class to test basic behavior.  that results in a single python file that has everything in it, and all you have to do to use it is add the appropriate lines to the weewx configuration file.

Vince Skahan

unread,
Feb 25, 2020, 4:01:59 PM2/25/20
to weewx-development
On Tuesday, February 25, 2020 at 12:38:57 PM UTC-8, mwall wrote:


On Tuesday, February 25, 2020 at 3:23:58 PM UTC-5, Vince Skahan wrote:
Before going too far down that path, I was wondering if there a generic 'query a URL that returns JSON' driver to start with ?

someone should implement that :)

in fact, it would be nice if that were a base class in weewx core that other drivers could use.  when i started weewx-interceptor i thought it would be that easy.  but it turns out that each hardware vendor does things just a little bit different than any other.

doing the http GET, receiving JSON data, parsing JSON data, and even doing it on a separate thread so you don't block the weewx engine - those are all pretty easy with python.

mapping the JSON fields to database fields, and sorting out the units - those are still squarely in the land of weewx.  the sensor_map and sensor_map_extensions patterns seem to work fairly well.



ok - let me fiddle on it a bit.  You guys are having far too much fun with 4.0 packaging :-)


Bob Weber

unread,
Feb 25, 2020, 7:22:06 PM2/25/20
to weewx-development


On Tuesday, February 25, 2020 at 3:23:58 PM UTC-5, Vince Skahan wrote:
I'm working with a user who is looking to get weewx running vs. his Davis WeatherLink IP device.   There's no driver for that currently, although there's an issue open on it in the weewx repo.



Am I missing something?  I have been using the Vantage driver for years with my WeatherLink IP data logger connected to an Envoy.  You can even tell the  WeatherLink IP data logger to stop updating the Davis website (at least in the older firmware I have).  Just set they type = ethernet, the host = data logger IP address and tcp_port = data logger port to use (probably 22222)

... bob
 

Thomas Keffer

unread,
Feb 25, 2020, 8:18:52 PM2/25/20
to Bob Weber, weewx-development
I suspect they meant the Davis WeatherLink Live logger: https://github.com/weewx/weewx/issues/412

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/4e002188-0c64-4d3a-b3df-35fa122a466f%40googlegroups.com.

Vince Skahan

unread,
Feb 25, 2020, 8:22:36 PM2/25/20
to weewx-development
I misspoke.  It's a Weatherlink Live device.   Not currrently supported according to https://github.com/weewx/weewx/issues/412

It broadcasts to UDP 22222 'if' you command it to do so, which you have to do at least once/day at a minimum.  Default is to broadcast for 20 minutes if you turn local broadcasts on without specifying a duration - https://weatherlink.github.io/weatherlink-live-local-api/ has details.

We did enough playing around with curl and tcpdump to verify the web page accurately represents what that box does.

 

gjr80

unread,
Feb 25, 2020, 8:30:39 PM2/25/20
to weewx-development
FWIW I wrote a Bloomsky driver a few years ago that hits the bloomsky API for json data every so often. Is not a combined service/driver nor is the mapping as sophisticated as described by Matthew.

https://github.com/gjr80/weewx-bloomsky

Code should be python 2/3 compatible but have not yet checked against WeeWX v4.

Gary

Vince Skahan

unread,
Mar 1, 2020, 12:52:07 PM3/1/20
to weewx-development
Thanks Gary.  Always good to have working examples to learn from.

I did a first pass based on Matthew's maxbotix driver which was simpler for my brain to get around yesterday.  I have an early draft driver that works ok versus test data, although the WeatherLink Live device's JSON is odd enough that I'm not too hopeful that I can make it as generic as I had hoped.  But it's early.  I'll have far more time to devote to it in a few days.
Reply all
Reply to author
Forward
0 new messages