Repository: mill1000/midea-msmart (python)

Issue:
Binary formatted total & current energy are off by a factor of 10
As originally reported here: https://github.com/mill1000/midea-ac-py/issues/230

Some users report that the total and current energy sensors are much to high. We are estimating by roughly a factor of 10 but haven't been able to conclusively determine if that's true.

I can't find any reference in the Lua or JS to this divide by 10.

Creating this issue just to track.

Pull request description:
Scale binary energy values by an additional factor of 10
Close #174 

When merged, this PR will need to be reverted before upgrading the msmart version https://github.com/mill1000/midea-ac-py/pull/248

Patch:
diff --git a/msmart/device/AC/command.py b/msmart/device/AC/command.py
index 6af37eb..85ae3b8 100644
--- a/msmart/device/AC/command.py
+++ b/msmart/device/AC/command.py
@@ -1024,10 +1024,11 @@ class EnergyUsageResponse(Response):
                    100 * decode_bcd(d[1]) +
                    1 * decode_bcd(d[2]) +
                    0.01 * decode_bcd(d[3]))
+            # Scale binary energy by an extra power of 10. See mill1000/midea-msmart#174
             binary = ((d[0] << 24) +
                       (d[1] << 16) +
                       (d[2] << 8) +
-                      d[3]) / 10
+                      d[3]) / 100
             return bcd, binary
 
         def parse_power(d: bytes) -> tuple[float, float]:


Test patch:
diff --git a/msmart/device/AC/test_command.py b/msmart/device/AC/test_command.py
index 28eacb1..fdede07 100644
--- a/msmart/device/AC/test_command.py
+++ b/msmart/device/AC/test_command.py
@@ -844,7 +844,7 @@ class TestGroupDataResponse(_TestResponseBase):
         """Test we decode binary energy usage responses correctly."""
         TEST_RESPONSES = {
             # https://github.com/mill1000/midea-ac-py/issues/204#issuecomment-2314705021
-            (150.4, .6, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
+            (15.04, .06, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
 
             # https://github.com/mill1000/midea-msmart/pull/116#issuecomment-2218753545
             (None, None, None): bytes.fromhex("aa20ac00000000000303c1210144000000000000000000000000000000000843bc"),
diff --git a/msmart/device/AC/test_device.py b/msmart/device/AC/test_device.py
index dc82018..80a9abb 100644
--- a/msmart/device/AC/test_device.py
+++ b/msmart/device/AC/test_device.py
@@ -297,7 +297,7 @@ class TestUpdateStateFromResponse(unittest.TestCase):
         """Test parsing of EnergyUsageResponses into device state with binary format."""
         TEST_RESPONSES = {
             # https://github.com/mill1000/midea-ac-py/issues/204#issuecomment-2314705021
-            (150.4, .6, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
+            (15.04, .06, 279.5): bytes.fromhex("aa22ac00000000000803c1210144000005e00000000000000006000aeb000000487a5e"),
 
             # https://github.com/mill1000/midea-msmart/pull/116#issuecomment-2218753545
             (None, None, None): bytes.fromhex("aa20ac00000000000303c1210144000000000000000000000000000000000843bc"),