bellrichm / WeeWX-MQTTSubscribe

A WeeWX service and driver that receives data from MQTT.
GNU General Public License v3.0
52 stars 13 forks source link

Rain Cumulative, Should Be Total #149

Closed gary-hammer closed 2 years ago

gary-hammer commented 2 years ago

I'm running WeeWX 4.70 and MQTTSubscribe 2.1.0-rc02 I am able to get good data, and the loop values show good rain values. The issue is that the "Rain Today" seems to be showing a cumulative amount. This is 0.12 for the day after erasing the weewx.sdb and the entire web directory. 5.76 in I have tried contains_total = true I'll include the raw values from the mosquitto server and the loop generated. I'm running WeeWX with as little config as possible, no changes at all to the web generation, units, labels, StdConvert, StdCalibrate, etc. Using the standard Seasons skin.

At a loss here.

loop-raw.txt

bellrichm commented 2 years ago

Sorry I'm not following you. I am guessing that you have something like this.

        [[[[rain24_in]]]]
            name = rain
            contains_total = true

And in the Current Conditions section the Rain Today is incrementing by the incoming value in the rain24_in field?

A log file will be needed. Set debug = 1, restart WeeWX and let it run through at least one archive record generation. Double check that no sensitive information is contained in the log.

gary-hammer commented 2 years ago

I'm attaching 4 runs with debug set. rain24_in with total enabled rain24_in with total disabled dayrain_in with total enabled dayrain_in with total disabled.

With total disabled, I get values in the skin, but incorrect. With total enabled I get 0.00 in the skin. MQTTInput-debug.zip

bellrichm commented 2 years ago

Thanks for the logs. I used the debug-dayrain_in log. Based on the field not changing from .18, it looks like in this archive period you got no rain. The 'contains total' algorithm is simple. At startup the value in the field, dayrain_in, is stored as the 'previous value'. After the first loop the 'incoming value' is compared to the 'previous value'. If the 'incoming value is greater than the 'previoua value', the 'WeeWX value' is set to 'incoming value' - 'previous value'. In the archive period of the log file, this results in a value of 0 being stored in the DB. The 'Rain Today' uses the WeeWX '$day.rain.sum' tag. This sums the rain in the DB for the given day. So unless you have some rain values in the DB, the skin will display 0. So at startup the 'historical' data is lost (or if WeeWX is stopped during a rain event some rain is lost). Without adding a lot of complexity, I don't see a way around this, but I will listen to any ideas. Net, during the archive period of this log, everything looks to be working as expected.

bellrichm commented 2 years ago

This discussion maybe of interest https://github.com/bellrichm/WeeWX-MQTTSubscribe/discussions/150

bellrichm commented 2 years ago

Is this still a problem?

gary-hammer commented 2 years ago

I haven't had rain for awhile. But, to be clear, I could not find a value that shows the amount of rain for the current day. If I use a logger, I get the rain for the day. WLL, same. Once it begins raining again, I'll try various options you've outlined on my test install and compare to my in service instance. Meantime, I'll close this.

gary-hammer commented 2 years ago

What would cause a doubling of rain? Today, we had rain. My production WeeWX shows 0.17" My test instance using MQTTSubscribe shows 0.34 on any skin installed.

Here's where it is getting the rain value. [[[[rain_in]]]] ignore = false # opt back in for this field name = rain

contains_total = true

gary-hammer commented 2 years ago

I tried both with contains_total set and not set.

gary-hammer commented 2 years ago

Got it with contains_total true