Skip to content

Commit

Permalink
Add entities for pv5 and pv6 for H3-Pro inverter (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagroe authored Nov 10, 2024
1 parent 7887be5 commit a1f7eea
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 5 deletions.
86 changes: 84 additions & 2 deletions custom_components/foxess_modbus/entities/entity_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def _pv_energy_total(key: str, models: list[EntitySpec], name: str, source_entit
addresses=[
ModbusAddressesSpec(input=[11101], models=Inv.KH_PRE119),
ModbusAddressesSpec(holding=[31044], models=Inv.KH_119),
ModbusAddressesSpec(holding=[39286, 39284], models=Inv.H3_PRO),
ModbusAddressesSpec(holding=[39286, 39285], models=Inv.H3_PRO),
],
name="PV4 Power",
)
Expand All @@ -371,6 +371,72 @@ def _pv_energy_total(key: str, models: list[EntitySpec], name: str, source_entit
name="PV4 Power Total",
source_entity="pv4_power",
)
yield _pv_voltage(
key="pv5_voltage",
addresses=[
ModbusAddressesSpec(holding=[39078], models=Inv.H3_PRO),
],
name="PV5 Voltage",
)
yield _pv_current(
key="pv5_current",
addresses=[
ModbusAddressesSpec(holding=[39079], models=Inv.H3_PRO),
],
name="PV5 Current",
scale=0.01,
)
yield _pv_power(
key="pv5_power",
addresses=[
ModbusAddressesSpec(holding=[39288, 39287], models=Inv.H3_PRO),
],
name="PV5 Power",
)
yield _pv_energy_total(
key="pv5_energy_total",
models=[
EntitySpec(
register_types=[RegisterType.INPUT, RegisterType.HOLDING],
models=Inv.H3_PRO,
),
],
name="PV5 Power Total",
source_entity="pv5_power",
)
yield _pv_voltage(
key="pv6_voltage",
addresses=[
ModbusAddressesSpec(holding=[39080], models=Inv.H3_PRO),
],
name="PV6 Voltage",
)
yield _pv_current(
key="pv6_current",
addresses=[
ModbusAddressesSpec(holding=[39081], models=Inv.H3_PRO),
],
name="PV6 Current",
scale=0.01,
)
yield _pv_power(
key="pv6_power",
addresses=[
ModbusAddressesSpec(holding=[39290, 39289], models=Inv.H3_PRO),
],
name="PV6 Power",
)
yield _pv_energy_total(
key="pv6_energy_total",
models=[
EntitySpec(
register_types=[RegisterType.INPUT, RegisterType.HOLDING],
models=Inv.H3_PRO,
),
],
name="PV6 Power Total",
source_entity="pv6_power",
)
yield ModbusLambdaSensorDescription(
key="pv_power_now",
models=[
Expand All @@ -392,7 +458,7 @@ def _pv_energy_total(key: str, models: list[EntitySpec], name: str, source_entit
models=[
EntitySpec(
register_types=[RegisterType.INPUT, RegisterType.HOLDING],
models=Inv.KH_SET | Inv.H3_PRO,
models=Inv.KH_SET,
),
],
sources=["pv1_power", "pv2_power", "pv3_power", "pv4_power"],
Expand All @@ -403,6 +469,22 @@ def _pv_energy_total(key: str, models: list[EntitySpec], name: str, source_entit
native_unit_of_measurement="kW",
icon="mdi:solar-power-variant-outline",
)
yield ModbusLambdaSensorDescription(
key="pv_power_now",
models=[
EntitySpec(
register_types=[RegisterType.INPUT, RegisterType.HOLDING],
models=Inv.H3_PRO,
),
],
sources=["pv1_power", "pv2_power", "pv3_power", "pv4_power", "pv5_power", "pv6_power"],
method=sum,
name="PV Power",
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement="kW",
icon="mdi:solar-power-variant-outline",
)


def _h1_current_voltage_power_entities() -> Iterable[EntityFactory]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
invbatpower=[39238, 39237],
battery_soc=[37612, 38310],
pwr_limit_bat_up=[46019, 46018],
pv_voltages=[39070, 39072, 39074, 39076],
pv_voltages=[39070, 39072, 39074, 39076, 39078, 39080],
),
models=Inv.H3_PRO,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@
"addresses": {
"holding": [
39286,
39284
39285
]
},
"key": "pv4_power",
Expand All @@ -1503,6 +1503,98 @@
"signed": true,
"type": "sensor"
},
{
"addresses": {
"holding": [
39079
]
},
"key": "pv5_current",
"name": "PV5 Current",
"scale": 0.01,
"signed": true,
"type": "sensor"
},
{
"key": "pv5_energy_total",
"method": "left",
"name": "PV5 Power Total",
"register_types": "dict_keys(['input', 'holding'])",
"source": "pv5_power",
"type": "integration-sensor",
"unit_time": "h"
},
{
"addresses": {
"holding": [
39288,
39287
]
},
"key": "pv5_power",
"name": "PV5 Power",
"scale": 0.001,
"signed": true,
"type": "sensor"
},
{
"addresses": {
"holding": [
39078
]
},
"key": "pv5_voltage",
"name": "PV5 Voltage",
"scale": 0.1,
"signed": true,
"type": "sensor"
},
{
"addresses": {
"holding": [
39081
]
},
"key": "pv6_current",
"name": "PV6 Current",
"scale": 0.01,
"signed": true,
"type": "sensor"
},
{
"key": "pv6_energy_total",
"method": "left",
"name": "PV6 Power Total",
"register_types": "dict_keys(['input', 'holding'])",
"source": "pv6_power",
"type": "integration-sensor",
"unit_time": "h"
},
{
"addresses": {
"holding": [
39290,
39289
]
},
"key": "pv6_power",
"name": "PV6 Power",
"scale": 0.001,
"signed": true,
"type": "sensor"
},
{
"addresses": {
"holding": [
39080
]
},
"key": "pv6_voltage",
"name": "PV6 Voltage",
"scale": 0.1,
"signed": true,
"type": "sensor"
},
{
"key": "pv_power_now",
"name": "PV Power",
Expand All @@ -1511,7 +1603,9 @@
"pv1_power",
"pv2_power",
"pv3_power",
"pv4_power"
"pv4_power",
"pv5_power",
"pv6_power"
],
"type": "lambda"
},
Expand Down

0 comments on commit a1f7eea

Please sign in to comment.