-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decimal values from meter become unprecise when being sent to mqtt #547
Comments
the debug output actually forces two digits of precision: Line 87 in 76e868f
the influxdb api forces six digits: Line 301 in 76e868f
mysmartgrid seems to only deal with integers: vzlogger/src/api/MySmartGrid.cpp Line 525 in 76e868f
only the volkszaehler api seems to not limit the precision (like mqtt): vzlogger/src/api/Volkszaehler.cpp Line 242 in 76e868f
|
i very much dislike the wording of the ticket title, the numbers are not "imprecise", rather, too much precision is used in the binary->decimal conversion. |
note that a very related floating-point related issue is discussed here: |
Software: vzlogger v0.8.1 based on heads/master-0-g27eb8d1566 from Wed, 28 Sep 2022 16:27:45 +0200
Device: Energy meter via IR D0
When reading absolute counter values from my energy meter, they are being transmitted correctly as the debug mode shows. When they're submitted to mqtt though, they seem to get the "float inaccuracy treatment" and are sometimes sent with lots of digits after the comma:
As 37298.16 represented in double float is 37298.160000000003492459654808 (which matches the digits shown above), is there any configuration I can use to prevent this from happening? Like setting the maximum precision on the channel (which I know is 2 digits)?
Edit:
I followed the code to this line which renders the value vor MQTT publish:
vzlogger/src/mqtt.cpp
Line 303 in 76e868f
The publish() method gets the channel struct already, so adding a
scale
orprecision
option to the channel configuration and then applying that in the above line (usingjson_object_new_double_s
) might be a possibility. What do you think?The text was updated successfully, but these errors were encountered: