diff --git a/custom_components/alphaess/button.py b/custom_components/alphaess/button.py index 392ee00..7b1a70e 100644 --- a/custom_components/alphaess/button.py +++ b/custom_components/alphaess/button.py @@ -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 diff --git a/custom_components/alphaess/coordinator.py b/custom_components/alphaess/coordinator.py index fa9a06d..3f2b9ca 100644 --- a/custom_components/alphaess/coordinator.py +++ b/custom_components/alphaess/coordinator.py @@ -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 ) @@ -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" @@ -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"