diff --git a/custom_components/foxess_modbus/entities/entity_descriptions.py b/custom_components/foxess_modbus/entities/entity_descriptions.py index 09f6e29..6208b99 100644 --- a/custom_components/foxess_modbus/entities/entity_descriptions.py +++ b/custom_components/foxess_modbus/entities/entity_descriptions.py @@ -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"}, @@ -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", diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.AIO_H3].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.AIO_H3].json index e5d14d6..f1fcc17 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.AIO_H3].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.AIO_H3].json @@ -1035,7 +1035,8 @@ "values": { "0": "Self Use", "1": "Feed-in First", - "2": "Back-up" + "2": "Back-up", + "4": "Peak Shaving" } } ] diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H1_G2].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H1_G2].json index 3ba3da0..32de430 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H1_G2].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H1_G2].json @@ -880,7 +880,8 @@ "values": { "0": "Self Use", "1": "Feed-in First", - "2": "Back-up" + "2": "Back-up", + "4": "Peak Shaving" } } ] diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3].json index e5d14d6..f1fcc17 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.H3].json @@ -1035,7 +1035,8 @@ "values": { "0": "Self Use", "1": "Feed-in First", - "2": "Back-up" + "2": "Back-up", + "4": "Peak Shaving" } } ] 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 f853170..7a862ca 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 @@ -1735,7 +1735,9 @@ "type": "select", "values": { "1": "Self Use", - "2": "Feed-in First" + "2": "Feed-in First", + "3": "Back-up", + "4": "Peak Shaving" } } ] diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KUARA_H3].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KUARA_H3].json index e5d14d6..f1fcc17 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KUARA_H3].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KUARA_H3].json @@ -1035,7 +1035,8 @@ "values": { "0": "Self Use", "1": "Feed-in First", - "2": "Back-up" + "2": "Back-up", + "4": "Peak Shaving" } } ] diff --git a/tests/test_entity_descriptions.py b/tests/test_entity_descriptions.py index 73708d8..0ab4152 100644 --- a/tests/test_entity_descriptions.py +++ b/tests/test_entity_descriptions.py @@ -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