Adding values from StdService trought StdConvert

38 views
Skip to first unread message

flor...@pre-vost.fr

unread,
Jul 5, 2020, 6:03:36 AM7/5/20
to weewx-development
Hi,

How can I pass values from a new service http://www.weewx.com/docs/customizing.htm#Adding_a_service

I would like to pass packet to Weewx Engine and not by using this method that I use at the moment : self.db_manager.addRecord(_packet_wl)

At the moment, I need to convert sensors values relative to target_unit in weewx.conf. But I would like that Weewx do it itself. 

flor...@pre-vost.fr

unread,
Jul 5, 2020, 6:32:51 AM7/5/20
to weewx-development
My service that I created to see the code : 
https://github.com/Drealine/WLLDriver/blob/master/bin/user/WLLArchive.py

gjr80

unread,
Jul 5, 2020, 8:07:09 AM7/5/20
to weewx-development
If I understand correctly you are trying to write a WLL driver that not only emits loop packets/archive records but also catchup archive records. if that is the case I think you are making this way more complex than it need be. A driver should only be concerned with emitting loop packets and archive records. These packets/records should be emitted using one of the three unit systems supported by WeeWX; US, METRIC or METRICWX. The driver should not care what unit system is used in the database, WeeWX takes care of any unit conversions before the StdArchive service saves any archive records to database. If the driver is more sophisticated and is able to emit 'catch up' archive records then the driver just neds to implement a genStartupRecords() method. There is no need to create a service to convert or save these (catchup) archive records as during startup WeeWX calls the driver's genStartupRecords() method and any archive records emitted are processed by WeeWX (eg units converted if required by StdConvert) and the archive record saved to database by StdArchive. Note that it is quite acceptable for a driver to convert an observation from one unit to another (say a temperature from C to F) but that should only be done for the purposes of getting the obs in a packet/record in the units used by the chosen unit system not to make the emitted packet/record agree with the database unit system (Note there are functions, largely in weewx.units, that can be imported to do various conversions for you). At the end of the day the driver chooses what unit system to use in packets/records it emits, the driver does not check the database unit system.

Gary

Florentin Prevost

unread,
Jul 5, 2020, 8:50:43 AM7/5/20
to weewx-development
Hi. Yes of course. I would like to request lost data when weewx restart.

For WLLArchive.py, I created while a service.
And I've WLLDriver.py on github which is the driver.

So if I understand, I need to implement genStartupRecords in my driver and not as a service ?

Florentin Prevost

unread,
Jul 5, 2020, 8:56:25 AM7/5/20
to weewx-development
If I want to request lost data when not data in loop packet, how can I implement it ?

I would like to create the request lost data from Weatherlink.com in service, and no in driver for more improvement.

gjr80

unread,
Jul 6, 2020, 12:28:02 AM7/6/20
to weewx-development
Exactly, you need to implement genStartupRecords() in your driver. Writing a service will add no benefits; rather it will add unnecessary complexity (there is already an established mechanism for catchup) and by stepping outside the established mechanism you risk your driver/service not working with future WeeWX versions. In short a lot of effort for no benefit.

genStartupRecords() accepts a timestamp and returns all archive records (not loop packets) it can that are timestamped after the timestamp concerned. You may chose to include a class in you driver that handles the interaction with WLL or you may chose to handle interaction with WLL through a number of methods in your driver.

I strongly suggest you have a look at some of the other drivers that have implemented genStartupRecords() and understand how it works. The vantage driver is one; cc3000, te923, wmr200, wmr300, ws23xx and ws28xx are others that implement genStartupRecords(). None use a web service/API to obtain historical archive records but that should not matter too much.

Gary

Reply all
Reply to author
Forward
0 new messages