On Thursday, January 25, 2018 at 8:59:11 AM UTC-5, Bill Morrow wrote:
>
> ...the maxbotix extension does part of this - it is both a driver and a 
>> service.  if you have a station already, you load it as a driver to augment 
>> that.  if you want to run multiple weewx instances, then you can run it as 
>> a driver.
>>
>
> You mean "service" in the latter case, I believe? 
>

yes, i mistyped, but i intended 'service' in the *former* case.

if you run a driver for your station (e.g., vantage), then the mqtt 
extension should load as a service to augment the station data.

if you do not have a station, then you would run the mqtt extension as a 
driver.

 

>
>> so if someone is keen to make this happen before i get around to it (my 
>> plate is beyond full right now), take a look at the weewx-maxbotix 
>> extension for a simple example.
>>
>
> I had a look at the maxbotix extesion. As a start, to extend my current 
> wxMesh 
> driver <https://github.com/morrowwm/weewxMQTT> to also act as a service:
>

the basic pattern is:

class XXXDriver(weewx.drivers.AbstractDevice):
    ...

class XXXService(weewx.engine.StdService):
    ...

class XXX(object):
    ...

where the XXX class encapsulates the interactions with the hardware/broker. 
 then the XXXDriver maps the XXX to the methods and behaviors that weewx 
expects from a driver, such as genLoopPackets to create each LOOP packet 
(see the customization guide for the required methods).  the XXXService 
maps the XXX to the methods and behaviors that weewx expects from a 
service, such as binding to LOOP and/or REC events then appending data to 
those dicts.

with this abstraction it is much easier to test the components.  for 
example, you can test the XXX object to see if you are subscribing or 
publishing mqtt events properly, without the weewx archiving and reporting 
layers.  once that works, you test the XXXDriver and XXXService 
capabilities.

m

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to