Page 1 of 1

RFX Meter / Uint32_t overflow

Posted: Sunday 17 May 2026 16:02
by qqlapraline
Hello everyone,

I've been using Domoticz for the past ... 13 years at least now.
My setup is somehow specific because I've been using numerous MySensors devices.

One of these devices is sending the actual usage of wooden pellet for my Mom's stove.
It is base on the V_VOLUME device for the MySensors family that is relying on .. RFXMeter devices on demotics.

I've been using 2025.1 (build 16598) for a while now because it took me some time to upgrade to Trixie on my Raspberry PI.
Once I've done the migration (to the lastest beta version), my famous V_VOLUME device had been having some trouble.
The updating value was: 3439258 but after a couple of minutes, Domoticz gave me a strange error:

Code: Select all

Error: GetJSonDevices: exception occurred: 'stoll' (3048/Conso Pellet Moteur)
I've been digging in to see what could be the error. After a while, I realized that the updated value was transformed to: 18446744072853842432
Which is basically: 2^64-855709184 ... and -855709184 is the int32 version of 3439258112 (the transformed float version of 3439258*1000.0f).
So, in a nuttshell, it comes from a bady typed conversion.

I've created a small fix on my setup. To do so, I've change the

Code: Select all

decode-RFXMeter
function in

Code: Select all

mainworker.cpp
.

I've replaced this line:

Code: Select all

unsigned long counter = (pResponse->RFXMETER.count1 << 24) + (pResponse->RFXMETER.count2 << 16) + (pResponse->RFXMETER.count3 << 8) + pResponse->RFXMETER.count4;
by this line:

Code: Select all

uint32_t counter = (static_cast<uint32_t>(pResponse->RFXMETER.count1) << 24) + (static_cast<uint32_t>(pResponse->RFXMETER.count2) << 16) + (static_cast<uint32_t>(pResponse->RFXMETER.count3) << 8) + static_cast<uint32_t>(pResponse->RFXMETER.count4);
And... it works for me !
I've looked back to the history of code and I really don't understand what could have changed. May be it's a matter of compilation on my raspberry pi ... any hint ?

Regards,

Qq.

Re: RFX Meter / Uint32_t overflow

Posted: Wednesday 20 May 2026 16:32
by gizmocuz
Thank you for reporting.

The patch is implemented in beta 17965

Re: RFX Meter / Uint32_t overflow

Posted: Thursday 21 May 2026 19:46
by qqlapraline
Tested and validated on my side !
Thanks, Gizmo.

Qq.