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
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def on_message(client, userdata, message):
"Daten nach dem Start oder Ladepunkt nicht erreichbar.")

self.client_error_context.reset_error_counter()
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=None,
charge_state=False,
imported=None,
exported=None,
currents=[0]*3,
phases_in_use=0,
power=0)
self.store.set(chargepoint_state)

def switch_phases(self, phases_to_use: int, duration: int) -> None:
with SingleComponentUpdateContext(self.fault_state, update_always=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ def get_values(self) -> None:
json_rsp["state"] == ChargingStatus.FINISHING.value or
json_rsp["state"] == ChargingStatus.UNAVAILABLE_CONN_OBJ.value):
raise Exception(f"Ladepunkt nicht verfügbar. Status: {ChargingStatus(json_rsp['state'])}")
self.store.set(chargepoint_state)
self.client_error_context.reset_error_counter()
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=None,
charge_state=False,
imported=None,
exported=None,
currents=[0]*3,
phases_in_use=0,
power=0)

self.store.set(chargepoint_state)


chargepoint_descriptor = DeviceDescriptor(configuration_factory=OpenWBDcAdapter)
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def get_values(self) -> None:
self.store.set(chargepoint_state)
except Exception as e:
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=False, charge_state=False, imported=None,
# bei im-/exported None werden keine Werte gepublished
exported=None, phases_in_use=0, power=0, currents=[0]*3)
chargepoint_state = ChargepointState(
plug_state=None, charge_state=False, imported=None,
# bei im-/exported None werden keine Werte gepublished
exported=None, phases_in_use=0, power=0, currents=[0]*3)
self.store.set(chargepoint_state)
raise e

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def get_values(self) -> None:
if self.client_error_context.error_counter_exceeded():
run_command(f"{Path(__file__).resolve().parents[3]}/modules/chargepoints/"
"openwb_series2_satellit/restart_protoss_satellite")
chargepoint_state = ChargepointState(
plug_state=None, charge_state=False, imported=None,
# bei im-/exported None werden keine Werte gepublished
exported=None, phases_in_use=0, power=0, currents=[0]*3)
self.store.set(chargepoint_state)
except AttributeError:
self._create_client()
self._validate_version()
Expand Down
10 changes: 9 additions & 1 deletion packages/modules/chargepoints/smartwb/chargepoint_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ def get_values(self) -> None:
max_evse_current=max_evse_current
)

self.store.set(chargepoint_state)
self.client_error_context.reset_error_counter()
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=None,
charge_state=False,
imported=None,
exported=None,
currents=[0]*3,
phases_in_use=0,
power=0)
self.store.set(chargepoint_state)

def clear_rfid(self) -> None:
with SingleComponentUpdateContext(self.fault_state):
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/common/component_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __init__(self,
power: float,
currents: List[float],
charge_state: bool,
plug_state: bool,
plug_state: Optional[bool],
serial_number: str = "",
charging_current: Optional[float] = 0,
charging_voltage: Optional[float] = 0,
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/common/store/_chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def update(self):
if self.state.phases_in_use:
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/phases_in_use", self.state.phases_in_use, 2)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/charge_state", self.state.charge_state, 2)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/plug_state", self.state.plug_state, 2)
if self.state.plug_state is not None:
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/plug_state", self.state.plug_state, 2)
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/rfid", self.state.rfid)
if self.state.rfid_timestamp is not None:
pub_to_broker("openWB/set/chargepoint/" + str(self.num) + "/get/rfid_timestamp", self.state.rfid_timestamp)
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/common/store/_chargepoint_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def update(self):
pub_to_broker(f"{topic_prefix}/powers", self.state.powers, 2)
pub_to_broker(f"{topic_prefix}/phases_in_use", self.state.phases_in_use, 2)
pub_to_broker(f"{topic_prefix}/charge_state", self.state.charge_state, 2)
pub_to_broker(f"{topic_prefix}/plug_state", self.state.plug_state, 2)
if self.state.plug_state is not None:
pub_to_broker(f"{topic_prefix}/plug_state", self.state.plug_state, 2)
pub_to_broker(f"{topic_prefix}/vehicle_id", self.state.vehicle_id)
pub_to_broker(f"{topic_prefix}/rfid", self.state.rfid)
pub_to_broker(f"{topic_prefix}/serial_number", self.state.serial_number)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ def store_state(chargepoint_state: ChargepointState) -> None:
current_commit=self.current_commit
)
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=False,
chargepoint_state = ChargepointState(plug_state=self.old_plug_state,
charge_state=False,
imported=self.old_chargepoint_state.imported,
exported=self.old_chargepoint_state.exported,
currents=self.old_chargepoint_state.currents,
currents=[0]*3,
phases_in_use=self.old_chargepoint_state.phases_in_use,
power=self.old_chargepoint_state.power)
power=0)

store_state(chargepoint_state)
self.old_chargepoint_state = chargepoint_state
Expand Down
17 changes: 11 additions & 6 deletions packages/modules/internal_chargepoint_handler/pro_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@ def store_state(chargepoint_state: ChargepointState) -> None:
store_state(self.old_chargepoint_state)
return self.old_chargepoint_state
except Exception as e:
if self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=False, charge_state=False, imported=None,
if self.old_chargepoint_state is None:
raise Exception(self.NO_DATA_SINCE_BOOT)
elif self.client_error_context.error_counter_exceeded():
chargepoint_state = ChargepointState(plug_state=self.old_chargepoint_state.plug_state,
charge_state=False,
# bei im-/exported None werden keine Werte gepublished
exported=None, phases_in_use=0, power=0, currents=[0]*3)
imported=None,
exported=None,
phases_in_use=0,
power=0,
currents=[0]*3)
store_state(chargepoint_state)
if isinstance(e, (requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError)):
raise Exception(self.NO_CONNECTION_TO_INTERNAL_CP)
else:
raise e
elif self.old_chargepoint_state is not None:
else:
store_state(self.old_chargepoint_state)
return self.old_chargepoint_state
else:
raise Exception(self.NO_DATA_SINCE_BOOT)

def perform_phase_switch(self, phases_to_use: int, duration: int) -> None:
super().switch_phases(phases_to_use, duration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import Mock

import pytest
import requests
from modules.internal_chargepoint_handler.pro_plus import SubData
from modules.common.component_state import ChargepointState
from modules.internal_chargepoint_handler.internal_chargepoint_handler_config import InternalChargepoint
Expand Down Expand Up @@ -66,7 +67,10 @@ def test_get_values_error_timer_exceed(setup_pro_plus: Callable[[], Tuple[ProPlu
# Exception werfen und Ladepunkt-Status zurücksetzen
# setup
pro_plus, mock_store_set = setup_pro_plus
monkeypatch.setattr(pro_plus, "request_values", Mock(side_effect=Exception(ProPlus.NO_CONNECTION_TO_INTERNAL_CP)))
pro_plus.old_chargepoint_state = ChargepointState(
plug_state=False, charge_state=False, imported=None, exported=None,
phases_in_use=0, power=0, currents=[0]*3)
monkeypatch.setattr(pro_plus, "request_values", Mock(side_effect=requests.exceptions.ConnectTimeout()))
monkeypatch.setattr(pro_plus.client_error_context, "error_counter_exceeded", lambda: True)

# execution
Expand Down