Skip to content

Commit

Permalink
Support dynamic max charge speed (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
vwt12eh8 authored Jul 22, 2022
1 parent 7c445bf commit 680da98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions custom_components/ecoflow/ecoflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def is_delta(product: int):
return 12 < product < 16


def is_delta_max(product: int):
return product == 13


def is_delta_mini(product: int):
return product == 15

Expand Down
35 changes: 31 additions & 4 deletions custom_components/ecoflow/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from . import (DOMAIN, EcoFlowConfigEntity, EcoFlowEntity, HassioEcoFlowClient,
request)
from .ecoflow import is_delta, is_delta_pro, is_power_station, send
from .ecoflow import (is_delta, is_delta_max, is_delta_mini, is_delta_pro,
is_power_station, send)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable):
Expand Down Expand Up @@ -61,9 +62,35 @@ async def async_set_native_value(self, value: float):

def _on_updated(self, data: dict[str, Any]):
super()._on_updated(data)
self._attr_extra_state_attributes = {
"custom_enable": (data["ac_in_limit_switch"] == 2),
}
voltage: float = data["ac_out_voltage_config"]
if is_delta_max(self._client.product):
if self._client.serial.startswith("DD"):
self._attr_native_max_value = 1600
elif voltage >= 220:
self._attr_native_max_value = 2000
elif voltage >= 120:
self._attr_native_max_value = 1800
elif voltage >= 110:
self._attr_native_max_value = 1650
else:
self._attr_native_max_value = 1500
elif is_delta_pro(self._client.product):
if voltage >= 240:
self._attr_native_max_value = 3000
elif voltage >= 230:
self._attr_native_max_value = 2900
elif voltage >= 220:
self._attr_native_max_value = 2200
elif voltage >= 120:
self._attr_native_max_value = 1800
elif voltage >= 110:
self._attr_native_max_value = 1650
else:
self._attr_native_max_value = 1500
elif is_delta_mini(self._client.product):
self._attr_native_max_value = 900
else:
self._attr_native_max_value = 1500


class DcInCurrentEntity(NumberEntity, EcoFlowConfigEntity):
Expand Down

0 comments on commit 680da98

Please sign in to comment.