Shelly Binding - value changes in the wrong order

OH 4.04

Using a Shelly 3M and get the totalKWH values in wrong order or overhaul. This creates negative values

The WLAN connection isn’t good but I assumed that the values were processed in the correct order

Compared with the MQTT Binding I didn’t get negative values and will now using MQTT instead of the Shelly Binding

2023-11-29 10:26:07.595 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 23.765 new: 23.75 diff: -0.01499939
2023-11-29 10:34:12.167 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 23.834 new: 23.828 diff: -0.006000519
2023-11-29 11:21:09.774 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.122 new: 24.119 diff: -0.0030002594
2023-11-29 14:15:17.852 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.403 new: 24.401 diff: -0.0020008087
2023-11-29 16:02:08.520 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.505 new: 24.504 diff: -9.994507E-4
2023-11-29 16:36:13.400 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.541 new: 24.54 diff: -9.994507E-4
2023-11-29 16:45:13.633 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.553 new: 24.551 diff: -0.0019989014
2023-11-30 06:27:09.774 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.963 new: 24.962 diff: -9.994507E-4
2023-11-30 06:44:14.170 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.984 new: 24.983 diff: -9.994507E-4
2023-11-30 06:50:13.731 [INFO ] [org.openhab.core.model.script.exec  ] - Energie Shelly - Wirkenergie Haus L1 - old: 24.991 new: 24.99 diff: -9.994507E-4
Number:Energy WirkenergieHausL1 "Wirkenergie Haus L1 [%.0f kWh]" (gDebug) { unit="kWh", channel="shelly:shellyem3:485519D69BAA:meter1#totalKWH" }
Number:Energy WirkenergieHausMQTTL1 "Wirkenergie Haus MQTT L1 [%.0f kWh]" (gDebug) { unit="kWh", channel="mqtt:topic:b:Shelly3EM:totalL1" }
rule "Test Wirkenergie Haus L1 - Shelly Binding"
when
    Item WirkenergieHausL1 changed
then
    val oldVal = if(!(previousState instanceof Number)) 0 else (previousState as Number).floatValue
    val newVal = if(!(newState instanceof Number))      0 else (newState as Number).floatValue
    val diff = newVal - oldVal

    if(diff < 0)
        logInfo("exec","Energie Shelly - Wirkenergie Haus L1 - old: {} new: {} diff: {}",oldVal,newVal,diff)
end

rule "Test Wirkenergie Haus L1 - MQTT Binding"
when
    Item WirkenergieHausMQTTL1 changed
then
    val oldVal = if(!(previousState instanceof Number)) 0 else (previousState as Number).floatValue
    val newVal = if(!(newState instanceof Number))      0 else (newState as Number).floatValue
    val diff = newVal - oldVal

    if(diff < 0)
        logInfo("exec","Energie MQTT - Wirkenergie Haus L1 - old: {} new: {} diff: {}",oldVal,newVal,diff)
end