Let me see if I can come up with something. Give me some time.

On Fri, Jan 21, 2022 at 1:37 PM Seth Ratner <[email protected]> wrote:

> Oh boy...
>
> I cant find any examples for that. If one exists, it will greatly reduce
> the number of questions I have...
>
> On Friday, January 21, 2022 at 3:24:07 PM UTC-6 [email protected] wrote:
>
>> You're getting close!
>>
>> You're going to have to implement get_aggregate(), as well as
>> get_scalar().
>>
>> The xtypes framework has no way of taking the calculation for
>> get_scalar() and using it to calculate an aggregate. You're going to have
>> to do it.  The good news is that once you've done it, then the framework
>> can use that to calculate a series on its own. This is where we will find
>> out how fast the calculation is.
>>
>> -tk
>>
>> On Fri, Jan 21, 2022 at 12:51 PM Seth Ratner <[email protected]> wrote:
>>
>>> Getting Closer, but still getting errors.
>>>
>>> I can now see the result in the archive loop (gets sent over MQTT). But
>>> with the seasons skin attempts to make a chart with it, I get:
>>>
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>> Caught unrecoverable exception in generator
>>> 'weewx.imagegenerator.ImageGenerator'
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****  chillHours
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****  Traceback (most recent call last):
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****    File "/usr/share/weewx/weewx/reportengine.py", line 196, in run
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****      obj.start()
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****    File "/usr/share/weewx/weewx/reportengine.py", line 281, in
>>> start
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****      self.run()
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****    File "/usr/share/weewx/weewx/imagegenerator.py", line 41, in run
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****      self.genImages(self.gen_ts)
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****    File "/usr/share/weewx/weewx/imagegenerator.py", line 177, in
>>> genImages
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****      start_vec_t, stop_vec_t ,data_vec_t =
>>> weewx.xtypes.get_series(var_type,
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****    File "/usr/share/weewx/weewx/xtypes.py", line 94, in get_series
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****      raise weewx.UnknownType(obs_type)
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****  weewx.UnknownType: chillHours
>>> Jan 21 14:40:39 Ratner-Orchard weewx[3122] ERROR weewx.reportengine:
>>>     ****  Generator terminated
>>>
>>> Here's the block I added in skin.conf
>>>
>>> [[[yearchill]]]
>>>             plot_type = bar
>>>             [[[[chillHours]]]]
>>>                 aggregate_type = cumulative
>>>                 aggregate_interval = day
>>>
>>>
>>> On Friday, January 21, 2022 at 2:14:11 PM UTC-6 Seth Ratner wrote:
>>>
>>>> I'm close, I think, except now I'm getting this every loop or report
>>>> generation.
>>>>
>>>> DEBUG weewx.wxservices: Unknown extensible type 'chillHours'
>>>>
>>>> There are a couple things I'm unsure of that might be causing this
>>>>
>>>> - I used the group type group_elapsed because it seemed like the best
>>>> fit
>>>> - The last line of the python file, modeled after the VaporPressure.py
>>>> example, is not part of either class, so I'm not sure what runs it.
>>>>
>>>> Here's the code:
>>>> https://github.com/lordratner/weewx_chillHours/blob/main/chill_hours.py
>>>>
>>>> It's been added to weewx.conf engine section in xtypes, and I've
>>>> confirmed the service is loading.
>>>>
>>>> Thoughts?
>>>>
>>>>
>>>> On Thursday, January 20, 2022 at 8:26:59 PM UTC-6 [email protected]
>>>> wrote:
>>>>
>>>>> I'd try it as a pure xtype first, and see what kind of performance I
>>>>> got. If it's slow, put it in the database.
>>>>>
>>>>> You can query the database directly, but the advantage of using xtypes
>>>>> system to do your queries is that it can automatically optimize whether or
>>>>> not to use the daily summaries.
>>>>>
>>>>> There's a brief section
>>>>> <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types#xtypes-api>
>>>>> in the wiki about the API. It's pretty self-explanatory, except about 
>>>>> where
>>>>> db_manager comes from. That's an instance of
>>>>> weewx.manager.DaySummaryManager. Look in weewx/manager.py for how to 
>>>>> create
>>>>> one. There are some convenient static methods for doing so.
>>>>>
>>>>> On Thu, Jan 20, 2022 at 6:15 PM Seth Ratner <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Thanks Tom
>>>>>>
>>>>>> Final questions for the night, I promise 🤣😂
>>>>>>
>>>>>> Would you put this one the database, or just let WeeWx calculate it
>>>>>> using the xtype each time?
>>>>>>
>>>>>> Second, is there an API or interface or whatever where another
>>>>>> application can query WeeWX for some sort of weather data? In this case,
>>>>>> I'd like my irrigation software to query WeeWX for the ET, total rain, 
>>>>>> and
>>>>>> chill hours of a given time frame.
>>>>>>
>>>>>> Or do I just have to read the database directly?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Jan 20, 2022, 19:15 Tom Keffer <[email protected]> wrote:
>>>>>>
>>>>>>> On Thu, Jan 20, 2022 at 4:01 PM Seth Ratner <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Would you add the step from the xType guide of adding chillHours to
>>>>>>>> [StdWXCalculate] [[Calculations]]? Or would the "synthetic type" 
>>>>>>>> concept
>>>>>>>> mean it only exists when it is called on.
>>>>>>>>
>>>>>>>> As I understand it, adding it to [StdWXCalculate] [[Calculations]]
>>>>>>>> would add chillHours to the loop, but it would not be in the archive 
>>>>>>>> unless
>>>>>>>> I also added a column for it with the same type name.
>>>>>>>>
>>>>>>>
>>>>>>> It doesn't hurt to add to StdWXCalculate, but it's really only
>>>>>>> necessary if you want to add the results to the database.  And,
>>>>>>> yes, it will only get added to the database if there's a matching 
>>>>>>> column in
>>>>>>> the schema.
>>>>>>>
>>>>>>>>
>>>>>>>> So on my Belchertown skin, where I want total Chill Hours from Oct
>>>>>>>> - May displayed, if I add it to the archive WeeWX will use the 
>>>>>>>> database to
>>>>>>>> calculate the total (just adding them together), whereas if I don't 
>>>>>>>> add it
>>>>>>>> to the archive, WeeWX will have to run the (if outTemp < 45 then 
>>>>>>>> chillHours
>>>>>>>> = archive_interval) for every archive row in that timespan, then sum 
>>>>>>>> that?
>>>>>>>>
>>>>>>>
>>>>>>> Maybe. For the ImageGenerator that comes with WeeWX, if a type is
>>>>>>> not available in the database, it will try to calculate it "on the fly"
>>>>>>> using xtypes. However, I have no idea what the Belchertown skin does. I
>>>>>>> kind of doubt it leverages xtypes.
>>>>>>> -tk
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>> the Google Groups "weewx-user" group.
>>>>>>> To unsubscribe from this topic, visit
>>>>>>> https://groups.google.com/d/topic/weewx-user/7ysYvSUMOOo/unsubscribe
>>>>>>> .
>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>> [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/weewx-user/CAPq0zEAdDBGTow7i55XfnGPzncQjdmiH%2BSk%3DL9_ZoE85QXKO%3Dw%40mail.gmail.com
>>>>>>> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEAdDBGTow7i55XfnGPzncQjdmiH%2BSk%3DL9_ZoE85QXKO%3Dw%40mail.gmail.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 [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/weewx-user/CAHTssjOF_Q65XveoboAwRV%2Br5-oNb8curD7LZTTmuD7Y0-EAjQ%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/weewx-user/CAHTssjOF_Q65XveoboAwRV%2Br5-oNb8curD7LZTTmuD7Y0-EAjQ%40mail.gmail.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 [email protected].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/weewx-user/cb666588-aced-461c-9171-9d48b89e85f5n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/weewx-user/cb666588-aced-461c-9171-9d48b89e85f5n%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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/8bb5d647-2f69-42b5-b5db-5b4c901e32f5n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/8bb5d647-2f69-42b5-b5db-5b4c901e32f5n%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEDpiJbAPWsG9AXcK%2BiPo-7N-opQSyGBs0Aup9sEhJNAFA%40mail.gmail.com.

Reply via email to