Skip to content

Commit

Permalink
Add SOH for some inverters
Browse files Browse the repository at this point in the history
Unsupported inverters: H1-G1
  • Loading branch information
MartB committed Nov 14, 2024
1 parent a1f7eea commit f799e31
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
19 changes: 19 additions & 0 deletions custom_components/foxess_modbus/entities/entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)],
Expand All @@ -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)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit f799e31

Please sign in to comment.