Skip to content

Commit

Permalink
Merge pull request #568 from canton7/bugfix/hex-version
Browse files Browse the repository at this point in the history
Fix which versions are hex, again
  • Loading branch information
canton7 authored Mar 17, 2024
2 parents 78825e8 + 0626d99 commit 029e1c7
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions custom_components/foxess_modbus/entities/entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,50 @@

def _version_entities() -> Iterable[EntityFactory]:
# Named so that they sort together
yield ModbusVersionSensorDescription(
key="master_version",
def _master_version(address: list[ModbusAddressSpec], is_hex: bool) -> ModbusVersionSensorDescription:
return ModbusVersionSensorDescription(
key="master_version",
address=address,
is_hex=is_hex,
name="Version: Master",
icon="mdi:source-branch",
)

yield _master_version(
address=[
ModbusAddressSpec(input=11016, models=Inv.H1_G1 | Inv.KH_PRE119),
ModbusAddressSpec(holding=30016, models=Inv.H1_G1 | Inv.H1_LAN | Inv.KH_119 | Inv.H3_SET),
ModbusAddressSpec(holding=30016, models=Inv.H1_G1 | Inv.H1_LAN | Inv.H3_SET),
],
is_hex=False,
name="Version: Master",
icon="mdi:source-branch",
)
yield ModbusVersionSensorDescription(
key="slave_version",
yield _master_version(
address=[
ModbusAddressSpec(holding=30016, models=Inv.KH_119),
],
is_hex=True,
)

def _slave_version(address: list[ModbusAddressSpec], is_hex: bool) -> ModbusVersionSensorDescription:
return ModbusVersionSensorDescription(
key="slave_version",
address=address,
is_hex=is_hex,
name="Version: Slave",
icon="mdi:source-branch",
)

yield _slave_version(
address=[
ModbusAddressSpec(input=11017, models=Inv.H1_G1 | Inv.KH_PRE119),
ModbusAddressSpec(holding=30017, models=Inv.H1_G1 | Inv.H1_LAN | Inv.KH_119 | Inv.H3_SET),
ModbusAddressSpec(holding=30017, models=Inv.H1_G1 | Inv.H1_LAN | Inv.H3_SET),
],
is_hex=False,
name="Version: Slave",
icon="mdi:source-branch",
)
yield _slave_version(
address=[
ModbusAddressSpec(holding=30017, models=Inv.KH_119),
],
is_hex=True,
)

def _manager_version(address: list[ModbusAddressSpec], is_hex: bool) -> ModbusVersionSensorDescription:
Expand All @@ -79,13 +104,13 @@ def _manager_version(address: list[ModbusAddressSpec], is_hex: bool) -> ModbusVe
yield _manager_version(
address=[
ModbusAddressSpec(input=11018, models=Inv.H1_G1 | Inv.KH_PRE119),
ModbusAddressSpec(holding=30018, models=Inv.H1_G1 | Inv.H1_LAN | Inv.H3_SET),
ModbusAddressSpec(holding=30018, models=Inv.H1_G1 | Inv.H1_LAN),
],
is_hex=False,
)
yield _manager_version(
address=[
ModbusAddressSpec(holding=30018, models=Inv.KH_119),
ModbusAddressSpec(holding=30018, models=Inv.KH_119 | Inv.H3_SET),
],
is_hex=True,
)
Expand Down

0 comments on commit 029e1c7

Please sign in to comment.