Skip to content

Commit

Permalink
Merge pull request #735 from FozzieUK/patch-3
Browse files Browse the repository at this point in the history
Adds additional BMS entities for H1 G2 and KH inverters on latest firmware
  • Loading branch information
canton7 authored Jan 26, 2025
2 parents 094fcfe + f0df542 commit 6590c64
Show file tree
Hide file tree
Showing 8 changed files with 1,186 additions and 69 deletions.
6 changes: 4 additions & 2 deletions custom_components/foxess_modbus/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class Inv(Flag):

H1_LAN = auto()
H1_G1 = auto()
H1_G2 = auto()
H1_G2_PRE144 = auto()
H1_G2_144 = auto()
H1_G2_SET = H1_G2_PRE144 | H1_G2_144

KH_PRE119 = auto()
KH_PRE133 = auto()
Expand All @@ -78,7 +80,7 @@ class Inv(Flag):

H3_PRO = auto()

ALL = H1_LAN | H1_G1 | H1_G2 | KH_SET | H3_SET | H3_PRO
ALL = H1_LAN | H1_G1 | H1_G2_SET | KH_SET | H3_SET | H3_PRO


class RegisterPollType(IntEnum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
period_end_address=41003,
enable_charge_from_grid_address=41001,
),
models=Inv.H1_G2,
models=Inv.H1_G2_SET,
),
],
period_start_key="time_period_1_start",
Expand Down Expand Up @@ -54,7 +54,7 @@
period_end_address=41006,
enable_charge_from_grid_address=41004,
),
models=Inv.H1_G2,
models=Inv.H1_G2_SET,
),
],
period_start_key="time_period_2_start",
Expand Down
138 changes: 77 additions & 61 deletions custom_components/foxess_modbus/entities/entity_descriptions.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
pwr_limit_bat_up=None,
pv_voltages=[39070, 39072],
),
models=Inv.H1_G2,
models=Inv.H1_G2_SET,
),
# The KH doesn't support anything above 44003
RemoteControlAddressSpec(
Expand Down
6 changes: 3 additions & 3 deletions custom_components/foxess_modbus/inverter_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def parse(version: str) -> "Version":
raise ValueError(f"Version {version} is not a valid version")
return Version(int(match[1]), int(match[2]))

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, Version) and self.major == other.major and self.minor == other.minor

def __hash__(self) -> int:
Expand Down Expand Up @@ -246,7 +246,7 @@ def inverter_capacity(self, inverter_model: str) -> int:
).add_connection_type(
ConnectionType.AUX,
RegisterType.HOLDING,
versions={None: Inv.H1_G2},
versions={Version(1, 44): Inv.H1_G2_PRE144, None: Inv.H1_G2_144},
special_registers=H1_G2_REGISTERS,
),
# Can be both e.g. H1-5.0 and H1-5.0-E, but not H1-5.0-E-G2
Expand All @@ -268,7 +268,7 @@ def inverter_capacity(self, inverter_model: str) -> int:
).add_connection_type(
ConnectionType.AUX,
RegisterType.HOLDING,
versions={None: Inv.H1_G2},
versions={Version(1, 44): Inv.H1_G2_PRE144, None: Inv.H1_G2_144},
special_registers=H1_G2_REGISTERS,
),
InverterModelProfile(InverterModel.AC1, r"^AC1-([\d\.]+)", capacity_parser=CapacityParser.H1)
Expand Down
Loading

0 comments on commit 6590c64

Please sign in to comment.