Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions custom_components/alphaess/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ async def async_press(self) -> None:
if self._key == AlphaESSNames.stopcharging:
_LOGGER.info("Stopped charging")
self._movement_state = None
await self._coordinator.Control_EV(self._serial, self._ev_serial, 0)
await self._coordinator.control_ev(self._serial, self._ev_serial, 0)

if self._key == AlphaESSNames.startcharging:
_LOGGER.info("started charging")
self._movement_state = None
await self._coordinator.Control_EV(self._serial, self._ev_serial, 1)
await self._coordinator.control_ev(self._serial, self._ev_serial, 1)

global last_discharge_update
global last_charge_update
Expand Down
8 changes: 4 additions & 4 deletions custom_components/alphaess/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ async def get_rounded_time() -> str:
return rounded_time.strftime("%H:%M")

@staticmethod
def calculate_time_window(time_period_minutes: int) -> tuple[str, str]:
async def calculate_time_window(time_period_minutes: int) -> tuple[str, str]:
"""Calculate start and end time for a given period."""
now = datetime.now()
start_time_str = TimeHelper.get_rounded_time()
start_time_str = await TimeHelper.get_rounded_time()
start_time = datetime.strptime(start_time_str, "%H:%M").replace(
year=now.year, month=now.month, day=now.day
)
Expand Down Expand Up @@ -358,7 +358,7 @@ async def _reset_charge_discharge_config(
async def update_discharge(self, name: str, serial: str, time_period: int) -> None:
"""Update discharge configuration for specified time period."""
bat_use_cap = self.hass.data[DOMAIN][serial].get(name)
start_time, end_time = self.time_helper.calculate_time_window(time_period)
start_time, end_time = await self.time_helper.calculate_time_window(time_period)

result = await self.api.updateDisChargeConfigInfo(
serial, bat_use_cap, 1, end_time, "00:00", start_time, "00:00"
Expand All @@ -372,7 +372,7 @@ async def update_discharge(self, name: str, serial: str, time_period: int) -> No
async def update_charge(self, name: str, serial: str, time_period: int) -> None:
"""Update charge configuration for specified time period."""
bat_high_cap = self.hass.data[DOMAIN][serial].get(name)
start_time, end_time = self.time_helper.calculate_time_window(time_period)
start_time, end_time = await self.time_helper.calculate_time_window(time_period)

result = await self.api.updateChargeConfigInfo(
serial, bat_high_cap, 1, end_time, "00:00", start_time, "00:00"
Expand Down