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.

m 

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/33b88eb7-2cbb-4821-9090-54c1a3f0d090%40googlegroups.com.

Reply via email to