Indeed! I share your appreciation for Weewx as a Python example. I’m retired, so didn’t have a “need” to learn Python, but did object oriented programming in Smalltalk and then C++ a long while ago, but ended up entering the management track, for good or ill. Nearing retirement, I set up WeeWX on an at-home server, and slowly used it as one of the examples to teach me Python, along with fail2ban and a couple of other things. I don’t say I am fluent in the language as I reserve that term for when I’ve built a multi-source file program “package” totaling thousands of lines, but I’ve grown quite comfortable editing source code for my particular unusual circumstances that are not generalizable - like tying in my sprinkler system to rain totals and soil moisture levels, etc. 



Sent from my iPhone
On Dec 25, 2023, at 10:49 AM, nfbarg...@gmail.com <nfbargman...@gmail.com> wrote:


Thanks, Tom.

I appreciate the tips.  Right now I am issuing SQL statements directly into the 'archive' and 'archive_day_rain' tables
for the barometer trend and day rain values.  This works as the access only occurs with each new record.

My basic understanding of Python is fine, it's all of the abstraction through the various classes where I tend to get lost.
Still this little project of mine has helped me immensely as it has given me a reason to understand the WeeWX internals
much better and the way an object oriented project ties together.

- Nate

On Sunday, December 24, 2023 at 7:39:34 PM UTC-6 Tom Keffer wrote:
In order to do this, a lot of infrastructure has to be in place. Take a look at the test file test_daily.py, function testTags (line 206).

It sets up a TimeBinder object (line 222). Once you have that, you can do things like

    print(tagStats.trend.barometer)

For many of these aggregates, you can use the xtypes system, which is a lot simpler to access. For example, to get the day's rain

    val_tuple = xtypes.get_aggregate('rain', timespan, 'sum', db_manager)

where timespan is the start/stop times over which the aggregation is to be taken, and db_manager is an open database manager object. It returns a ValueTuple.

If you're not a Python programmer, it's going to be tough. :-(

-tk

On Sun, Dec 17, 2023 at 3:38 PM nfbarg...@gmail.com <nfbarg...@gmail.com> wrote:
This likely has everything to do with my lack of Python acuity than WeeWX.

When obtaining values for a user extension that does not have an associated skin so I am not using the Cheetah Generator, how might I call into the tag system to get the data such as 'trend.barometer'?  in cheetahgenerator.py I see the Stats class that looks like it should be what should be called but I don't see it subclassed anywhere but is part of 'default_search_list'.

Primarily I am interested in 'trend.barometer' and 'day.rain'.  The rest I am getting from the latest archive record.  I've not found any extensions that use the tag system like this that I can be inspired by so I am asking the experts.

TIA

- Nate

--
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 on the web visit https://groups.google.com/d/msgid/weewx-development/b4a1b9d6-2e1e-4132-8731-477c2d6018f8n%40googlegroups.com.

--
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-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/882990f1-4e76-4bb7-a63d-40e8c25b387cn%40googlegroups.com.

--
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-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/04AEE55C-110D-4BB2-8BC7-63BD50F991B9%40gmail.com.

Reply via email to