Skip to content

Commit

Permalink
use 'maxPossibleChargingCurrentInA' as set_icmax when mode set to FAS…
Browse files Browse the repository at this point in the history
…TEST
  • Loading branch information
marq24 committed Jan 4, 2024
1 parent 8a02fa3 commit 2b67a7b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions custom_components/senec/pysenec_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2584,15 +2584,13 @@ async def app_set_wallbox_mode(self, mode_to_set_in_lc: str, wallbox_num: int =
idx = wallbox_num - 1
if self._app_raw_wallbox[idx] is not None:
cur_mode = self._app_raw_wallbox[idx]["chargingMode"].lower()
cur_min_current = self._app_raw_wallbox[idx]["configuredMinChargingCurrentInA"]
# if the NEW mode will be the LOCKED mode we will keep/store the previous active mode
if mode_to_set_in_lc == APP_API_WEB_MODE_LOCKED:
self._app_last_wallbox_modes[idx] = cur_mode
else:
self._app_last_wallbox_modes[idx] = None
else:
cur_mode = "unknown"
cur_min_current = -1

if cur_mode == mode_to_set_in_lc:
_LOGGER.debug(f"APP-API skipp mode change since '{mode_to_set_in_lc}' already set")
Expand Down Expand Up @@ -2620,12 +2618,20 @@ async def app_set_wallbox_mode(self, mode_to_set_in_lc: str, wallbox_num: int =
await asyncio.sleep(2)
await self.app_get_wallbox_data(wallbox_num=wallbox_num)
if self._app_raw_wallbox[idx] is not None:
new_min_current = self._app_raw_wallbox[idx]["configuredMinChargingCurrentInA"]
if mode_to_set_in_lc == APP_API_WEB_MODE_FASTEST:
new_min_current_tmp = self._app_raw_wallbox[idx]["maxPossibleChargingCurrentInA"]
else:
new_min_current_tmp = self._app_raw_wallbox[idx]["configuredMinChargingCurrentInA"]

new_min_current = str(round(float(new_min_current_tmp), 2))
cur_min_current = str(round(IntBridge.lala_cgi.wallbox_set_icmax[idx], 2))

if cur_min_current != new_min_current:
_LOGGER.debug(f"APP-API 2sec after mode change: configuredMinChargingCurrentInA changed from {cur_min_current} to {new_min_current} need to sync with local unit")
_LOGGER.debug(f"APP-API 2sec after mode change: local set_ic_max {cur_min_current} will be updated to {new_min_current}")
await IntBridge.lala_cgi.set_nva_wallbox_set_icmax(pos=idx, value=float(new_min_current), sync=False)
else:
_LOGGER.debug(f"APP-API 2sec after mode change: configuredMinChargingCurrentInA remains [old: {cur_min_current} new: {new_min_current}]")
_LOGGER.debug(f"APP-API 2sec after mode change: NO CHANGE! - local set_ic_max: {cur_min_current} equals: {new_min_current}]")

else:
_LOGGER.debug(f"APP-API could not read wallbox data 2sec after mode change")
else:
Expand Down

0 comments on commit 2b67a7b

Please sign in to comment.