You could access the WeeWX database API directly. For example, the equivalent query for $day($days_ago=2).rain.sum would be
weewx.xtypes.get_aggregate('rain', ts, 'sum', db_manager) where 'ts' is the timespan that covers two days ago. This one is easy because the "xtypes" interface is reasonably well documented. See the Wiki article, "WeeWX V4 user defined types <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types>". But some queries might require extensions, both from users and within WeeWX itself. Provided you're not doing anything too fancy, I'd just do the queries directly to the database. On Wed, Feb 16, 2022 at 6:50 AM Seth Ratner <lordrat...@gmail.com> wrote: > Hello everyone, > > Part of this is my weakness in python, but: > > I'm writing an independent program in python that will calculate > irrigation times and durations. To do this it needs information from the > WeeWX database such as: > > - Total ET for a particular day or time range > - Total rain for a day or time range > - Current rain rate > > The current rain rate I can just use MQTT for, but the others require > database queries. > > I know WeeWX can pull all sorts of queries using tags, but can I use that > system from a separate python program? Is it just a simple import? A > complex import? Something else entirely? > > For instance, in WeeWX $day($days_ago=2).rain.sum gets me what I want. If > I can somehow use that in my own program, I would be able to completely > remove any need to query the database directly. > > But if it's not how python works, oh well. > > Thanks! > Seth > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/b1bdae38-699e-494c-af65-79e282789f9dn%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-user/b1bdae38-699e-494c-af65-79e282789f9dn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEA9yDLP1Lxq7hbkro1QF2CVQyNsm953wGNZUtaSw0XrRQ%40mail.gmail.com.