Skip to content

Commit 012e01f

Browse files
authored
fix smartwb phases in use not charging (#2393)
1 parent 35f6557 commit 012e01f

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

packages/modules/chargepoints/smartwb/chargepoint_module.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, config: SmartWB) -> None:
2020
"Ladepunkt", "chargepoint"))
2121
self.client_error_context = ErrorTimerContext(
2222
f"openWB/set/chargepoint/{self.config.id}/get/error_timestamp", CP_ERROR, hide_exception=True)
23-
self.phases_in_use = 1
23+
self.old_phases_in_use = 1
2424
self.session = req.get_http_session()
2525

2626
def set_current(self, current: float) -> None:
@@ -55,12 +55,11 @@ def get_values(self) -> None:
5555

5656
currents = [json_rsp["currentP1"], json_rsp["currentP2"], json_rsp["currentP3"]]
5757

58-
if currents[2] > 3:
59-
self.phases_in_use = 3
60-
elif currents[1] > 3:
61-
self.phases_in_use = 2
62-
elif currents[0] > 3:
63-
self.phases_in_use = 1
58+
phases_in_use = sum(1 for current in currents if current > 3)
59+
if phases_in_use == 0:
60+
phases_in_use = self.old_phases_in_use
61+
else:
62+
self.old_phases_in_use = phases_in_use
6463

6564
if json_rsp.get("voltageP1"):
6665
voltages = [json_rsp["voltageP1"], json_rsp["voltageP2"], json_rsp["voltageP3"]]
@@ -86,7 +85,7 @@ def get_values(self) -> None:
8685
imported=json_rsp["meterReading"] * 1000,
8786
plug_state=plug_state,
8887
charge_state=charge_state,
89-
phases_in_use=self.phases_in_use,
88+
phases_in_use=phases_in_use,
9089
voltages=voltages,
9190
rfid=tag,
9291
serial_number=mac,

0 commit comments

Comments
 (0)