Skip to content

Commit

Permalink
Set max export limit from the inverter
Browse files Browse the repository at this point in the history
  • Loading branch information
mletenay committed Apr 14, 2024
1 parent 43d3d77 commit c7f934a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions custom_components/goodwe/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def _get_setting_unit(inverter: Inverter, setting: str) -> str:
native_unit_of_measurement=UnitOfPower.WATT,
native_step=100,
native_min_value=0,
native_max_value=10000,
getter=lambda inv: inv.get_grid_export_limit(),
mapper=lambda v: v,
setter=lambda inv, val: inv.set_grid_export_limit(val),
Expand All @@ -64,7 +63,7 @@ def _get_setting_unit(inverter: Inverter, setting: str) -> str:
native_unit_of_measurement=PERCENTAGE,
native_step=1,
native_min_value=0,
native_max_value=100,
native_max_value=200,
getter=lambda inv: inv.get_grid_export_limit(),
mapper=lambda v: v,
setter=lambda inv, val: inv.set_grid_export_limit(val),
Expand Down Expand Up @@ -131,9 +130,15 @@ async def async_setup_entry(
_LOGGER.debug("Could not read inverter setting %s", description.key)
continue

entities.append(
InverterNumberEntity(device_info, description, inverter, current_value)
)
entity = InverterNumberEntity(device_info, description, inverter, current_value)
# Adjust the max value according to actual inverter power (if provided)
if (
inverter.rated_power
and description.key == "grid_export_limit"
and description.native_unit_of_measurement == UnitOfPower.WATT
):
entity.native_max_value = inverter.rated_power
entities.append(entity)

async_add_entities(entities)

Expand Down

0 comments on commit c7f934a

Please sign in to comment.