Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Peak Shaving work mode for H3 Inverters & H1 (Gen 2) #737

Merged
merged 9 commits into from
Jan 22, 2025
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
Loading