I think you've fallen into a corner case.

All variables referenced in a [[Corrections]] must be in the same packet or
record. So, if the two MQTT feeds are creating separate LOOP packets, then
any correction won't have all the variables it needs and will fail.

However, archive records are different. By then, the two streams should
have been combined into a single archive record (by the accumulators).
However, the engine figures that the corrections were already applied in
the LOOP packets, so it does not apply them again. So, the correction is
never tried.

To do what you want to do you'll have to write a service that looks for new
archive record events and applies the calculation there. It would be quite
simple. Using your silly example, it would look something like this (NOT
TESTED):

# File user/mqttfix.py:
import weewx
from weewx.engine import StdService

class MQTTFix(StdService):
    def __init__(self, engine, config_dict):
        super(MQTTFix, self).__init__(engine, config_dict)

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

    def new_archive_record(self, event):
        # The record may not have 'outTemp' and 'barometer', so be prepared
for a key error exception
        try:
            event.record['outTemp'] = event.record['outTemp'] /
event.record['barometer']
        except KeyError:
            pass

Then you add user.mqttfix.MQTTFix to the end of process_services in
weewx.conf

-tk

On Sun, Jul 26, 2020 at 8:23 AM Norbert F <fume1...@gmail.com> wrote:

> Hello
> I am using weewx feeded from two different mqtt sources (mqtt-subscribe),
> is there a way to use StdCalibrate to calulate from different sources.
>
> Example:
> source1 feeds: outTemp, outHumidity.......
> source2 feeds: barometer, windSpeed, rain......
>
> If i try
>
> [StdCalibrate]
>     [[Corrections]]
>         outTemp = outTemp /  outHumidity
>
> this is working, but when i use values from different sources like
>
> [StdCalibrate]
>     [[Corrections]]
>         outTemp = outTemp /  barometer
>
> nothing is calculated. ( This formulas are only silly examples )
>
> Thanks for help.
>
> --
> 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/7e07e58c-b5bf-47e8-a798-924d8062a177o%40googlegroups.com
> .
>

-- 
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/CAPq0zEBD%2Bqv3iHL6ox9DXRrCrdCY52dqZVdvDsYomRNDekxZ7g%40mail.gmail.com.

Reply via email to