From 7887be518618c613128a1727170cfd791fe9a95f Mon Sep 17 00:00:00 2001 From: Dave Foster Date: Thu, 17 Oct 2024 21:13:04 +0100 Subject: [PATCH] Fix for InvBatPower2 register endian change (#694) * Fix for InvBatPower2 register endian change the latest H3 Pro firmware Master 1.53, Manager 1.22 has flipped the endian for this register; which now matches the Fox modbus definition (V1.05.00.00) see https://github.com/nathanmarlor/foxess_modbus/discussions/685#discussioncomment-10811413 --- .../foxess_modbus/entities/entity_descriptions.py | 6 +++++- ...st_entity_descriptions_for_model[Inv.H3_PRO].json | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/custom_components/foxess_modbus/entities/entity_descriptions.py b/custom_components/foxess_modbus/entities/entity_descriptions.py index 29425cd7..f9258c70 100644 --- a/custom_components/foxess_modbus/entities/entity_descriptions.py +++ b/custom_components/foxess_modbus/entities/entity_descriptions.py @@ -1197,7 +1197,11 @@ def _invbatpower(index: int | None, addresses: list[ModbusAddressesSpec]) -> Ite addresses=[ # It does genuinely look like these two are the wrong way around, see # https://github.com/nathanmarlor/foxess_modbus/discussions/516#discussioncomment-9569558 - ModbusAddressesSpec(holding=[39235, 39236], models=Inv.H3_PRO), + # ^^^^ Following on from this previous comment, + # the H3 Pro firmware from Master 1.53, Manager 1.22 has corrected the endian for this + # batpower2 register; it now matches the Fox modbus definition V1.05.00.00 + # see https://github.com/nathanmarlor/foxess_modbus/discussions/685#discussioncomment-10811413 + ModbusAddressesSpec(holding=[39236, 39235], models=Inv.H3_PRO), ], ) diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3_PRO].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3_PRO].json index f00028d7..f2dafcb3 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3_PRO].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3_PRO].json @@ -52,8 +52,8 @@ { "addresses": { "holding": [ - 39235, - 39236 + 39236, + 39235 ] }, "key": "battery_charge_2", @@ -117,8 +117,8 @@ { "addresses": { "holding": [ - 39235, - 39236 + 39236, + 39235 ] }, "key": "battery_discharge_2", @@ -979,8 +979,8 @@ { "addresses": { "holding": [ - 39235, - 39236 + 39236, + 39235 ] }, "key": "invbatpower_2",