Skip to content

Commit

Permalink
Support AC-3.0 charge/discharge rates (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdpuk authored Mar 16, 2023
1 parent 7732797 commit 1a72775
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
7 changes: 6 additions & 1 deletion custom_components/givenergy_local/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ def inverter_model(self) -> Model:
@property
def inverter_max_battery_power(self) -> Model:
"""Get the maximum battery charge/discharge power for this model."""
return 3600 if self.inverter_model == Model.Gen2 else 2600
if self.inverter_model == Model.Gen2:
return 3600
elif self.inverter_model == Model.AC:
return 3000
else:
return 2600


class BatteryEntity(CoordinatorEntity[Plant]):
Expand Down
14 changes: 3 additions & 11 deletions custom_components/givenergy_local/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import annotations

from givenergy_modbus.client import GivEnergyClient
from givenergy_modbus.model.inverter import Model
from homeassistant.components.number import (
NumberDeviceClass,
NumberEntity,
Expand Down Expand Up @@ -147,17 +146,10 @@ def watts_to_api_value(self, watts: int) -> int:
inverter capabilities.
"""
target_value = int(watts / self.battery_power_step)
max_step = int(self.inverter_max_battery_power / self.battery_power_step)

if self.inverter_model == Model.Gen2:
# Gen2 inverters: Numbering stops at 36, then jumps to 50 = 3.6kW
if target_value > 36:
target_value = 50
else:
# Everything else: Numbering stops at 30, then jumps to 50 = 2.6kW
if target_value > 30:
target_value = 50

return target_value
# The API always jumps to 50 to represent the maximum possible value
return 50 if target_value > max_step else target_value


class InverterBatteryChargeLimitNumber(InverterBatteryPowerLimitNumber):
Expand Down

0 comments on commit 1a72775

Please sign in to comment.