Reporting dynamic calculated values without storing them in database.

76 views
Skip to first unread message

Peter Fletcher

unread,
Jan 10, 2025, 5:19:52 PMJan 10
to weewx-development
I am working on a service which will take current energy production data from my PV solar monitoring system and store it in the weewx database, to be reported to a modified version of the (pre-4.2) Seasons skin. The data I want to store is already being written at 5 min intervals to a transient file on the Raspberry Pi on which I am running weewx, so so far, so easy. I would also like to display, in 'Current Conditions', but not store, current totals for various periods (e.g. Today, this month, this utility billing period, this year). I assume that the Report generator could compute these from the archived energy generation values, but accurate values for all these totals are already available in the same file that contains the current production data, and it seems stupid, as well as potentially error-prone, to recalculate them. Is it possible just to make such values available to the report generator - e.g. by inserting appropriate tuples in Loop or Archive records within the Service?

Peter Fletcher

unread,
Jan 22, 2025, 4:32:31 PMJan 22
to weewx-development
I would really appreciate any responses, even if the right answer is: "No, you can't do that!"

Tom Keffer

unread,
Jan 22, 2025, 4:51:55 PMJan 22
to Peter Fletcher, weewx-development
This is exactly what XTypes are for. 

For an example of using XTypes in an energy monitoring context, see weewx-brultech.

On Fri, Jan 10, 2025 at 2:19 PM 'Peter Fletcher' via weewx-development <weewx-de...@googlegroups.com> wrote:
I am working on a service which will take current energy production data from my PV solar monitoring system and store it in the weewx database, to be reported to a modified version of the (pre-4.2) Seasons skin. The data I want to store is already being written at 5 min intervals to a transient file on the Raspberry Pi on which I am running weewx, so so far, so easy. I would also like to display, in 'Current Conditions', but not store, current totals for various periods (e.g. Today, this month, this utility billing period, this year). I assume that the Report generator could compute these from the archived energy generation values, but accurate values for all these totals are already available in the same file that contains the current production data, and it seems stupid, as well as potentially error-prone, to recalculate them. Is it possible just to make such values available to the report generator - e.g. by inserting appropriate tuples in Loop or Archive records within the Service?

--
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 weewx-developm...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-development/c51f55d7-340f-4ed4-a295-0e559f4ced03n%40googlegroups.com.

Tom Keffer

unread,
Jan 22, 2025, 8:02:25 PMJan 22
to Peter Fletcher, weewx-development
OK, I get it --- somewhere in the file are the aggregate values that you need. I can think of two ways to approach this:
  1. If you only need tags for use in the Cheetah generator, you could write a search list extension, which would read the file and make the contents available as a tag. You'd end up with tags such as $month_total_energy.
  2. Write a WeeWX service to read your file, then add the values to the current record. Then, the values would be available as $current.month_total_energy --- not the most intuitive tag.
That's all I can think of right now.

-tk



On Wed, Jan 22, 2025 at 3:58 PM Peter Fletcher <pe...@fletchers-uk.com> wrote:

All of my 'aggregate' values will be directly available in the file I mentioned in my original message - there will be no need for any actual calculations.

On 1/22/2025 5:42 PM, Tom Keffer wrote:
Yes, an observation value implemented as an XType can be used pretty much anywhere a database value can be used. 

However, because they are not stored in the daily summaries, calculating some aggregates of XTypes can be quite expensive. Something to be aware of.



On Wed, Jan 22, 2025 at 2:36 PM Peter Fletcher <pe...@fletchers-uk.com> wrote:

Thanks!

I had obviously not read the introductory documentation (which is all I had read) on XTypes carefully enough, since I had thought it (only) allowed adding new types to be manipulated and stored in the database. I will have to read the full documentation with more care.

Tom Keffer

unread,
Jan 23, 2025, 9:56:29 AMJan 23
to Peter Fletcher, weewx-development
You can add the values for just the archive records by hooking into the event NEW_ARCHIVE_RECORD.

On Thu, Jan 23, 2025 at 6:05 AM Peter Fletcher <pe...@fletchers-uk.com> wrote:

Either of these approaches look to be more straightforward than using XTypes. The search list extension approach probably involves less overhead, since the code presumably only runs when Cheetah does. For the second approach, I assume that I would have to add the values on every loop, even though they would only be used for reporting.

Reply all
Reply to author
Forward
0 new messages