diff --git a/custom_components/foxess_modbus/entities/entity_descriptions.py b/custom_components/foxess_modbus/entities/entity_descriptions.py index 6208b99..fed90d0 100644 --- a/custom_components/foxess_modbus/entities/entity_descriptions.py +++ b/custom_components/foxess_modbus/entities/entity_descriptions.py @@ -1911,6 +1911,7 @@ def _inner( batvolt: list[ModbusAddressesSpec], bat_current: list[ModbusAddressesSpec], battery_soc: list[ModbusAddressesSpec], + battery_soh: list[ModbusAddressesSpec], battery_temp: list[ModbusAddressesSpec], bms_cell_temp_high: list[ModbusAddressesSpec], bms_cell_temp_low: list[ModbusAddressesSpec], @@ -1954,6 +1955,17 @@ def _inner( signed=False, validate=[Range(0, 100)], ) + yield ModbusBatterySensorDescription( + key=f"battery_soh{key_suffix}", + addresses=battery_soh, + bms_connect_state_address=bms_connect_state_address, + name=f"Battery{name_infix} SoH", + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement="%", + signed=False, + validate=[Range(0, 100)], + ) yield ModbusBatterySensorDescription( key=f"battery_temp{key_suffix}", addresses=battery_temp, @@ -2040,6 +2052,11 @@ def _inner( ModbusAddressesSpec(holding=[31024], models=Inv.H1_G1 | Inv.H1_LAN | Inv.H1_G2 | Inv.KH_119), ModbusAddressesSpec(holding=[31038], models=Inv.H3_SET), ], + battery_soh=[ + ModbusAddressesSpec(input=[11104], models=Inv.KH_PRE119), + ModbusAddressesSpec(holding=[37624], models=Inv.H1_G2 | Inv.KH_119), + ModbusAddressesSpec(holding=[31090], models=Inv.H3_SET), + ], battery_temp=[ ModbusAddressesSpec(input=[11038], models=Inv.H1_G1 | Inv.KH_PRE119), ModbusAddressesSpec(holding=[31023], models=Inv.H1_G1 | Inv.H1_LAN | Inv.H1_G2 | Inv.KH_119), @@ -2068,6 +2085,7 @@ def _inner( batvolt=[ModbusAddressesSpec(holding=[37609], models=Inv.H3_PRO)], bat_current=[ModbusAddressesSpec(holding=[37610], models=Inv.H3_PRO)], battery_soc=[ModbusAddressesSpec(holding=[37612], models=Inv.H3_PRO)], + battery_soh=[ModbusAddressesSpec(holding=[37624], models=Inv.H3_PRO)], battery_temp=[ModbusAddressesSpec(holding=[37611], models=Inv.H3_PRO)], bms_cell_temp_high=[ModbusAddressesSpec(holding=[37617], models=Inv.H3_PRO)], bms_cell_temp_low=[ModbusAddressesSpec(holding=[37618], models=Inv.H3_PRO)], @@ -2081,6 +2099,7 @@ def _inner( batvolt=[ModbusAddressesSpec(holding=[38307], models=Inv.H3_PRO)], bat_current=[ModbusAddressesSpec(holding=[38308], models=Inv.H3_PRO)], battery_soc=[ModbusAddressesSpec(holding=[38310], models=Inv.H3_PRO)], + battery_soh=[ModbusAddressesSpec(holding=[38322], models=Inv.H3_PRO)], battery_temp=[ModbusAddressesSpec(holding=[38309], models=Inv.H3_PRO)], bms_cell_temp_high=[ModbusAddressesSpec(holding=[38315], models=Inv.H3_PRO)], bms_cell_temp_low=[ModbusAddressesSpec(holding=[38316], models=Inv.H3_PRO)], 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 f1fcc17..b1cddbe 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 @@ -109,6 +109,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 31090 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [ 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 32de430..c05ab30 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 @@ -97,6 +97,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 37624 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [ 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 f1fcc17..b1cddbe 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 @@ -109,6 +109,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 31090 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [ 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 7a862ca..8070c35 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 @@ -177,6 +177,30 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 37624 + ] + }, + "key": "battery_soh_1", + "name": "Battery 1 SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, + { + "addresses": { + "holding": [ + 38322 + ] + }, + "key": "battery_soh_2", + "name": "Battery 2 SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [ diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_119].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_119].json index fa32b63..3ebc8af 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_119].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_119].json @@ -97,6 +97,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 37624 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [ diff --git a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_PRE119].json b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_PRE119].json index 85f14ed..da7f8c3 100644 --- a/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_PRE119].json +++ b/tests/__snapshots__/test_entity_descriptions/test_entity_descriptions_for_model[Inv.KH_PRE119].json @@ -109,6 +109,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "input": [ + 11104 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "input": [ 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 f1fcc17..b1cddbe 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 @@ -109,6 +109,18 @@ "signed": false, "type": "sensor" }, + { + "addresses": { + "holding": [ + 31090 + ] + }, + "key": "battery_soh", + "name": "Battery SoH", + "scale": null, + "signed": false, + "type": "sensor" + }, { "addresses": { "holding": [