Just had a thought.

I assume that weewxd is using software record generation. Check in the log.
If so, [[Corrections]] does not apply the corrections to archive records
because, in theory, the correction should have already been applied in the
LOOP packets. Obviously that's not happening here.

I've created issue #895 <https://github.com/weewx/weewx/issues/895> to
track.

In the meantime, what you can do is create a simple service
<https://www.weewx.com/docs/customizing.htm#Adding_a_service> to do the
calculation. It would look something like this (NOT TESTED):

from weewx.engine import StdService

class Power(StdService):

  def __init__(self, engine, config_dict):
    super(Power, self).__init__(engine, config_dict)

    self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)

  def new_archive_record(self, event)
    ampere = event.record.get('ampere')
    linevoltage = event.record.get('linevoltage')
    if ampere is not None and linevoltage is not None:
      event.record['consumption'] = ampere * linevoltage
    else:
      event.record['consumption'] = None

This will work provided that linevoltage and ampere do not vary too much
over the archive interval. Because you are using short intervals (60
seconds), this is probably not much of a problem.







On Tue, Oct 17, 2023 at 6:12 PM Mks Mk <[email protected]> wrote:

> from database
>
> dateTime usUnits interval consumption          ampere
>  linevoltage      pf
> 1697583060 1            1                        90.84233333          141
>         0.9
> 1697583120 1            1                        110.3686667          141
>         0.9
> 1697583180 1            1                        77.51766667
>  140.5           0.9
> 1697583240 1            1                        101.4843333          141
>         0.9
> 1697583300 1            1                        100.0026667          141
>         0.9
> 1697583360 1            1                        4.977666667          141
>         0.9
> 1697583420 1            1                        4.907666667   142
>     0.9
> 1697583480 1            1                        4.927666667   141.5
>       0.9
> 1697583540 1            1                        4.886
>  141.3333333   0.9
> 1697583600 1            1                        4.867666667          141
>          0.9
> 1697583660 1            1                        4.877666667          141
>          0.9
> 1697583720 1            1                        78.94533333          141
>          0.9
> 1697583780 1            1                        90.26166667
>  140.6666667     0.9
>
>
> On Wednesday, October 18, 2023 at 3:35:05 AM UTC+3 Mks Mk wrote:
>
>> Hi Gary
>>
>> it all started here
>> https://groups.google.com/g/weewx-user/c/ltOVkcY1fKc/m/7sQSVGN_AQAJ
>>
>> we were using fixed value for the incoming grid line to calculate the
>> consumption but it was not accurate enough so we added new sensor to read
>> the grid incoming line voltage.
>> earlier this formula worked consumption = ampere * 117 / 1000 * 0.88
>> but  consumption = ampere * linevoltage / 1000 * 0.88 did not work
>> the linevoltage input comes from different sensor than ampere,  these
>> two reading are generated in different loops, so based on Tom advice the
>> weewx correction will not work
>> thank you
>>
>> On Wednesday, October 18, 2023 at 1:28:55 AM UTC+3 gjr80 wrote:
>>
>>> So what does
>>>
>>> consumption = ((ampere * linevoltage) /1000) * 0.88
>>>
>>> do?
>>>
>>> Gary
>>> On Wednesday, 18 October 2023 at 08:26:25 UTC+10 [email protected]
>>> wrote:
>>>
>>>> Hi Tom
>>>>
>>>> we run weewx directly and found that 'ampere' & 'linevoltage' are in
>>>> different loop because the data are coming from two different sensors by
>>>> sdr.py driver.
>>>> how we can combine these loops into one so weewx can process this
>>>> formula, or what can we do to get this calculation done.?
>>>>
>>>> Thank you for your support
>>>>
>>>> On Tuesday, October 17, 2023 at 9:26:38 PM UTC+3 Tom Keffer wrote:
>>>>
>>>>> The only symbols that can be used in the [[Corrections]] formula are
>>>>> other types in the archive record. So unless 'ampere', 'linevoltage', and
>>>>> 'pf' all appear in the record, the correction will not work.
>>>>>
>>>>> On Tue, Oct 17, 2023 at 9:48 AM Mks Mk <[email protected]> wrote:
>>>>>
>>>>>> we want to improve the accuracy of our home energy monitor and we
>>>>>> added new sensor to read the main line voltage so we got two sensors and
>>>>>> the data is logged in weewx database.
>>>>>>
>>>>>>     [[sensor_map]]
>>>>>>
>>>>>>         ampere = current.***.EfPacket
>>>>>>         linevoltage = payload5.*****.RadioHeadASKPacket
>>>>>>
>>>>>> the database have these columns which we created
>>>>>>
>>>>>> consumption
>>>>>> ampere
>>>>>> linevoltage
>>>>>> pf
>>>>>>
>>>>>> we want to calculate the energy consumption so we added this
>>>>>> correction
>>>>>>
>>>>>> [StdCalibrate]
>>>>>>
>>>>>>     [[Corrections]]
>>>>>>         # For each type, an arbitrary calibration expression can be
>>>>>> given.
>>>>>>         # It should be in the units defined in the StdConvert section.
>>>>>>         # Example:
>>>>>>         foo = foo + 0.2
>>>>>> pf = 0.88
>>>>>>         consumption = ((ampere * linevoltage) /1000) * pf
>>>>>>
>>>>>> unfortunately weewx did nothing nor it complained about it. can weewx
>>>>>> process such formula?
>>>>>>
>>>>>> thanks
>>>>>>
>>>>>> --
>>>>>> 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/26effb7c-ad33-4de8-a9a0-f1390012ec5an%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/weewx-user/26effb7c-ad33-4de8-a9a0-f1390012ec5an%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/fa342793-222a-4773-9bde-5bf97cf88dddn%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/fa342793-222a-4773-9bde-5bf97cf88dddn%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/CAPq0zEC3xes2-RStpQc74xFB248Ta-VKTKGarNy8eOuCfLxXcA%40mail.gmail.com.

Reply via email to