How do i change the type of aggregation record that is created for a custom data source?

60 views
Skip to first unread message

Thomas Carlin

unread,
Sep 1, 2019, 5:20:00 PM9/1/19
to weewx-user
Good afternoon, I hope everyone is enjoying their labor day weekend!

I have a custom data source that I wrote a driver for, and have recently changed it from pulling data when the archive packet is created, to when the loop packet is received.  This is working well, and everything is pulling correctly, but now I have an issue with the creation of the archive packet.  Previously, the device that I received the data from performed the aggregation, but now it is producing much more frequent information, and the driver/weewx service needs to handle the aggregation.  

Several of my data sources are similar to 'rain' where I want to count the total of something used or collected, and it looks like the archive packet is created using the average.  Based on the documentation, I need to implement genArchiveRecords() for these to specify how the data is aggregated, but I can't find any example code of how this is done.  Could you please point me in the correct direction for modifying this, or to a driver with some example code that I can modify for my needs?

If this is more fitting for the development group, please move it there.

Many thanks,

Thomas

Thomas Keffer

unread,
Sep 1, 2019, 5:50:06 PM9/1/19
to weewx-user
As LOOP packets arrive, they are accumulated in "accumulators." When it's time to generate a new archive record, the value are "extracted." As you note, the default is to take the average value over the interval, but there are alternatives, which can be changed in weewx.conf. The drivers are not involved.

For example, say you have a type, which you want to treat similarly to rain. Call it "rainish". Here's how you could extract a value that is the sum from all LOOP packets.

[Accumulator]
  [[rainish]]
    extractor = sum

Other types of extraction are possible, such as "min", "max", "last", "count", and "noop" (extract nothing).

-tk

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/bf7d69e5-7c93-438d-846d-279667f0299d%40googlegroups.com.

Thomas Carlin

unread,
Sep 1, 2019, 6:18:45 PM9/1/19
to weewx-user
Thanks Tom,

Thanks for the fast response!  I created the section that you said in weewx.conf, see below, and now I don't get any data in the archive table, also included below, with previous AVG values for comparison sake.  Suggestions?

[Accumulator]
    [[kwh]]
        extractor = sum
    [[IrrigationFlow]]
        extractor = sum
sqlite> select datetime, kwh, IrrigationFlow from archive where datetime >=1567374900;
dateTime|kwh|IrrigationFlow
1567374900|0.009349|0.0
1567375200|0.0100596551724138|0.0
1567375800||
1567376100||
sqlite>


?

Thomas Keffer

unread,
Sep 1, 2019, 7:04:24 PM9/1/19
to weewx-user
Hmmm.

If you run weewxd directly from the console command line, what values do you see go by on the console?

--
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 weewx-user+...@googlegroups.com.

Thomas Carlin

unread,
Sep 1, 2019, 7:27:27 PM9/1/19
to weewx-user
I think you may be correct... It looks like only half or so of the data was actually pulling from the sensors.  I'll have to figure that issue out, but it doesn't look like the problem was in the config changes we made.  

Thanks again Tom!
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Thomas Carlin

unread,
Sep 2, 2019, 1:28:24 PM9/2/19
to weewx-user
Just wanted to confirm for any reading this later, After fixing my sensor issues, this change did exactly what I needed to do, and I am now seeing SUM values instead of average in the archive packets.

Thanks again,
Reply all
Reply to author
Forward
0 new messages