Tom

Thanks for the reply.  

As I started implementing genArchiveRecords() I came to realize that it is 
a very elegant solution.

However, I am running into a snag and it is related to the type of data 
available when I request historical data - the meter only supplies total 
kWh delivered, with no info about the price.  The data received from the 
restful service used in the loop date include data such as price / kWh, 
which I use to calculate the cost and also store that in the database.  

I am thinking about some workarounds for the genArchiveRecords() methods.  
Since the historical data request does not contain the cost data it would 
be useful to be able to pull the cost from the last record in the database 
and use that when making up the historical data - not perfect but better 
than empty fields. 

Is it at all possible to access the database safely from the driver to read 
the content of the last record?

On Sunday, 24 March 2019 08:44:12 UTC-7, Tom Keffer wrote:
>
> If you implement the method genArchiveRecords() there should be no reason 
> to do this. It will pass in as its only argument the last timestamp in the 
> database. So, do your retrieval since that timestamp. It should be a 
> generator function, yielding records.
>
> -tk
>
> On Sun, Mar 24, 2019 at 8:21 AM Louis De Lange <[email protected] 
> <javascript:>> wrote:
>
>> I am busy writing a new driver to capture electricity data from a meter 
>> send out the data using a restful service using POST requests - the driver 
>> is based heavily on the Interceptor driver..  
>>
>> I have the whole thing working correctly as initially intended, but now 
>> it would be nice to add some features.
>>
>> The meter allows me to download historical data for any time that weewx 
>> was perhaps offline.  However, to do this is a practical way I need to know 
>> the time of the last record in the database.  When I try to open the 
>> database from the driver using 
>>
>> db_manager = 
>> self.engine.db_binder.get_manager(data_binding='name_of_binding', 
>> initialize=True)
>>
>>
>> or 
>>
>> db_manager = weewx.manager.open_manager_with_config(config_dict, 
>> data_binding='name_of_binding')
>>
>>
>> as suggested in the customization guide it fails.
>>
>> This raises the question, is it possible to access the database from the 
>> driver? - and if yes, how?
>>
>> Thanks in advance
>>
>> Louis
>>
>

Reply via email to