Skip to content

Commit

Permalink
Merge pull request #737 from FozzieUK/patch-4
Browse files Browse the repository at this point in the history
Add Peak Shaving work mode for H3 Inverters & H1 (Gen 2)
  • Loading branch information
canton7 authored Jan 22, 2025
2 parents 464d02f + 1edf5eb commit 54da800
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
11 changes: 10 additions & 1 deletion custom_components/foxess_modbus/entities/entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ def _configuration_entities() -> Iterable[EntityFactory]:
key="work_mode",
address=[
ModbusAddressSpec(input=41000, models=Inv.H1_G1 | Inv.KH_PRE119),
ModbusAddressSpec(holding=41000, models=Inv.H1_G1 | Inv.H1_G2 | Inv.KH_119 | Inv.H3_SET),
ModbusAddressSpec(holding=41000, models=Inv.H1_G1 | Inv.KH_119),
],
name="Work Mode",
options_map={0: "Self Use", 1: "Feed-in First", 2: "Back-up"},
Expand All @@ -2115,6 +2115,15 @@ def _configuration_entities() -> Iterable[EntityFactory]:
},
)

yield ModbusWorkModeSelectDescription(
key="work_mode",
address=[
ModbusAddressSpec(holding=41000, models=Inv.H1_G2 | Inv.H3_SET),
],
name="Work Mode",
options_map={0: "Self Use", 1: "Feed-in First", 2: "Back-up", 4: "Peak Shaving"},
)

# Sensors are a bit nicer to look at: keep for consistency with other numbers
yield ModbusSensorDescription(
key="max_charge_current",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,8 @@
"values": {
"0": "Self Use",
"1": "Feed-in First",
"2": "Back-up"
"2": "Back-up",
"4": "Peak Shaving"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@
"values": {
"0": "Self Use",
"1": "Feed-in First",
"2": "Back-up"
"2": "Back-up",
"4": "Peak Shaving"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,8 @@
"values": {
"0": "Self Use",
"1": "Feed-in First",
"2": "Back-up"
"2": "Back-up",
"4": "Peak Shaving"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,9 @@
"type": "select",
"values": {
"1": "Self Use",
"2": "Feed-in First"
"2": "Feed-in First",
"3": "Back-up",
"4": "Peak Shaving"
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,8 @@
"values": {
"0": "Self Use",
"1": "Feed-in First",
"2": "Back-up"
"2": "Back-up",
"4": "Peak Shaving"
}
}
]
2 changes: 1 addition & 1 deletion tests/test_entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_entity_descriptions_for_model(model: Inv, snapshot_json: SnapshotAssert
# syrupy doesn't like keys which aren't strings
def _process(d: Any) -> None:
if isinstance(d, dict):
for k, v in d.items():
for k, v in d.copy().items():
if not isinstance(k, str):
del d[k]
d[str(k)] = v
Expand Down

0 comments on commit 54da800

Please sign in to comment.