Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and display evse current #2025

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions packages/control/chargepoint/chargepoint_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Get:
fault_str: str = NO_ERROR
fault_state: int = 0
imported: float = 0
max_evse_current: Optional[int] = None
phases_in_use: int = 0
plug_state: bool = False
power: float = 0
Expand Down
3 changes: 2 additions & 1 deletion packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,8 @@ def process_chargepoint_get_topics(self, msg):
self._validate_value(msg, bool)
elif "/get/fault_state" in msg.topic:
self._validate_value(msg, int, [(0, 2)])
elif "/get/evse_current" in msg.topic:
elif ("/get/evse_current" in msg.topic or
"/get/max_evse_current"):
self._validate_value(msg, float, [(0, 0), (6, 32), (600, 3200)])
elif ("/get/fault_str" in msg.topic or
"/get/state_str" in msg.topic or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, config: OpenWBseries2Satellit) -> None:
f"openWB/set/chargepoint/{self.config.id}/get/error_timestamp", CP_ERROR, hide_exception=True)
self._create_client()
self._validate_version()
self.max_evse_current = self._client.evse_client.get_max_current()

def delay_second_cp(self, delay: float):
if self.config.configuration.duo_num == 0:
Expand Down Expand Up @@ -93,7 +94,8 @@ def get_values(self) -> None:
plug_state=plug_state,
charge_state=charge_state,
phases_in_use=phases_in_use,
serial_number=self._client.meter_client.get_serial_number()
serial_number=self._client.meter_client.get_serial_number(),
max_evse_current=self.max_evse_current
)
self.store.set(chargepoint_state)
self.client_error_context.reset_error_counter()
Expand Down
5 changes: 4 additions & 1 deletion packages/modules/chargepoints/smartwb/chargepoint_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def get_values(self) -> None:
else:
tag = None

max_evse_current = json_rsp["maxCurrent"]

resp = self.session.get('http://'+ip_address+'/evseHost', timeout=timeout)
mac = resp.json()["list"][0]["mac"]

Expand All @@ -87,7 +89,8 @@ def get_values(self) -> None:
phases_in_use=self.phases_in_use,
voltages=voltages,
rfid=tag,
serial_number=mac
serial_number=mac,
max_evse_current=max_evse_current
)

self.store.set(chargepoint_state)
Expand Down
9 changes: 6 additions & 3 deletions packages/modules/chargepoints/smartwb/smartwb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class TestSmartWb:
plug_state=True,
charge_state=False,
phases_in_use=3,
serial_number="94:B9:7E:69:F0:D1"
serial_number="94:B9:7E:69:F0:D1",
max_evse_current=32
)
SAMPLE_V1 = {
"type": "parameters",
Expand Down Expand Up @@ -61,7 +62,8 @@ class TestSmartWb:
charge_state=True,
rfid="0a1b2c3d",
rfid_timestamp=1652683252,
serial_number="94:B9:7E:69:F0:D1"
serial_number="94:B9:7E:69:F0:D1",
max_evse_current=16
)
SAMPLE_V2 = {
"type": "parameters",
Expand Down Expand Up @@ -100,7 +102,8 @@ class TestSmartWb:
rfid="0a1b2c3d",
rfid_timestamp=1652683252,
phases_in_use=1,
serial_number="94:B9:7E:69:F0:D1"
serial_number="94:B9:7E:69:F0:D1",
max_evse_current=16
)
SAMPLE_NOT_CHARGING_V2 = {
"type": "parameters",
Expand Down
4 changes: 3 additions & 1 deletion packages/modules/common/component_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def __init__(self,
soc: Optional[float] = None,
soc_timestamp: Optional[int] = None,
evse_current: Optional[float] = None,
vehicle_id: Optional[str] = None):
vehicle_id: Optional[str] = None,
max_evse_current: Optional[int] = None):
self.currents, self.powers, self.voltages = _calculate_powers_and_currents(currents, powers, voltages)
self.frequency = frequency
self.imported = imported
Expand All @@ -188,6 +189,7 @@ def __init__(self,
self.soc = soc
self.soc_timestamp = soc_timestamp
self.evse_current = evse_current
self.max_evse_current = max_evse_current
self.vehicle_id = vehicle_id


Expand Down
5 changes: 5 additions & 0 deletions packages/modules/common/evse.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ def deactivate_precise_current(self) -> None:
def set_current(self, current: int) -> None:
time.sleep(0.1)
self.client.write_registers(1000, current, unit=self.id)

def get_max_current(self) -> int:
time.sleep(0.1)
current = self.client.read_holding_registers(2007, ModbusDataType.UINT_16, unit=self.id)
return current
1 change: 1 addition & 0 deletions packages/modules/common/store/_chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def update(self):
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/soc_timestamp", self.state.soc_timestamp)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/evse_current", self.state.evse_current)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/vehicle_id", self.state.vehicle_id)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/max_evse_current", self.state.max_evse_current)


def get_chargepoint_value_store(id: int) -> ValueStore[ChargepointState]:
Expand Down
2 changes: 2 additions & 0 deletions packages/modules/common/store/_chargepoint_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def update(self):
"/get/serial_number", self.state.serial_number)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) +
"/get/evse_current", self.state.evse_current, 2)
pub_to_broker("openWB/set/internal_chargepoint/" + str(self.num) +
"/get/max_evse_current", self.state.max_evse_current, 2)


def get_internal_chargepoint_value_store(id: int) -> ValueStore[ChargepointState]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, local_charge_point_num: int,
if self._client.evse_client.is_precise_current_active() is False:
self._client.evse_client.activate_precise_current()
self._precise_current = self._client.evse_client.is_precise_current_active()
self.max_evse_current = self._client.evse_client.get_max_current()

def set_current(self, current: float) -> None:
with SingleComponentUpdateContext(self.fault_state, update_always=False):
Expand Down Expand Up @@ -107,7 +108,8 @@ def store_state(chargepoint_state: ChargepointState) -> None:
power_factors=power_factors,
rfid=last_tag,
evse_current=self.set_current_evse,
serial_number=serial_number
serial_number=serial_number,
max_evse_current=self.max_evse_current
)
except Exception as e:
self._client.read_error += 1
Expand Down
1 change: 1 addition & 0 deletions packages/modules/internal_chargepoint_handler/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self,
parent_cp: int,
hierarchy_id: int) -> None:
self.socket_max_current = get_hardware_configuration_setting("max_c_socket")
self.chargepoint_state.max_evse_current = self.socket_max_current
log.debug(f"Konfiguration als Buchse mit maximal {self.socket_max_current}A Ladestrom je Phase.")
super().__init__(local_charge_point_num, client_handler, parent_hostname, parent_cp, hierarchy_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@pytest.mark.parametrize(
"old_chargepoint_state, published_topics",
[(None, 42),
[(None, 44),
(OLD_CHARGEPOINT_STATE, 2)]

)
Expand Down