Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
benderl committed Jul 31, 2023
1 parent 44dba2e commit b1c6d6b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/control/chargepoint/chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def check_min_max_current(self, required_current: float, phases: int, pv: bool =
else:
required_current = min(required_current, self.template.data.max_current_multi_phases)
if required_current != required_current_prev and msg is None:
msg = ("Die Einstellungen in der Ladepunkt-Vorlage beschränken den Strom auf "
msg = ("Die Einstellungen in dem Ladepunkt-Profil beschränken den Strom auf "
f"maximal {required_current} A.")
self.set_state_and_log(msg)
return required_current
Expand Down
2 changes: 1 addition & 1 deletion packages/control/chargepoint/chargepoint_state_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def update(self):
try:
ev_list[vehicle].charge_template = copy.deepcopy(self.ev_charge_template_data["ct" + str(
ev_list[vehicle].data.charge_template)])
# zuerst das aktuelle Template laden
# zuerst das aktuelle Profil laden
ev_list[vehicle].ev_template = copy.deepcopy(self.ev_template_data["et" + str(
ev_list[vehicle].data.ev_template)])
except Exception:
Expand Down
6 changes: 3 additions & 3 deletions packages/control/chargepoint/chargepoint_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class CpTemplateData:
id: int = 0
max_current_multi_phases: int = 32
max_current_single_phase: int = 32
name: str = "Standard Ladepunkt-Vorlage"
name: str = "Standard Ladepunkt-Profil"
rfid_enabling: bool = False
valid_tags: List = field(default_factory=empty_list_factory)


class CpTemplate:
""" Vorlage für einen Ladepunkt.
""" Profil für einen Ladepunkt.
"""

def __init__(self):
Expand Down Expand Up @@ -101,5 +101,5 @@ def get_ev(self, rfid, assigned_ev):
return num, message
except Exception:
log.exception(
"Fehler in der Ladepunkt-Template Klasse")
"Fehler in der Ladepunkt-Profil Klasse")
return num, "Keine Ladung, da ein interner Fehler aufgetreten ist: " + traceback.format_exc()
2 changes: 1 addition & 1 deletion packages/control/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def switch_on_timer_expired(self, chargepoint: Chargepoint) -> None:

SWITCH_OFF_STOP = "Ladevorgang nach Ablauf der Abschaltverzögerung gestoppt."
SWITCH_OFF_WAITING = "Ladevorgang wird nach Ablauf der Abschaltverzögerung {}s gestoppt."
SWITCH_OFF_NO_STOP = ("Stoppen des Ladevorgangs verhindert, da in der Fahrzeug-Vorlage die Einstellung"
SWITCH_OFF_NO_STOP = ("Stoppen des Ladevorgangs verhindert, da in dem Fahrzeug-Profil die Einstellung"
" 'Ladung aktiv halten' aktiviert ist.")
SWITCH_OFF_EXCEEDED = "Abschaltschwelle während der Verzögerung überschritten."
SWITCH_OFF_NOT_CHARGING = ("Da das EV nicht lädt und die Abschaltschwelle erreicht wird, "
Expand Down
2 changes: 1 addition & 1 deletion packages/control/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def __copy_ev_data(self) -> None:
try:
self.ev_data[vehicle].charge_template = self.ev_charge_template_data["ct" + str(
self.ev_data[vehicle].data.charge_template)]
# zuerst das aktuelle Template laden
# zuerst das aktuelle Profil laden
self.ev_data[vehicle].ev_template = self.ev_template_data["et" + str(
self.ev_data[vehicle].data.ev_template)]
except Exception:
Expand Down
12 changes: 6 additions & 6 deletions packages/control/ev.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def chargemode_factory() -> Chargemode:

@dataclass
class ChargeTemplateData:
name: str = "Standard-Ladeprofil-Vorlage"
name: str = "Standard-Lade-Profil"
disable_after_unplug: bool = False
prio: bool = False
load_default: bool = False
Expand All @@ -110,7 +110,7 @@ class ChargeTemplateData:

@dataclass
class EvTemplateData:
name: str = "Standard-Fahrzeug-Vorlage"
name: str = "Standard-Fahrzeug-Profil"
max_current_multi_phases: int = 16
max_phases: int = 3
phase_switch_pause: int = 2
Expand Down Expand Up @@ -427,7 +427,7 @@ def check_min_max_current(
min_current = self.data.control_parameter.required_current
if required_current < min_current:
required_current = min_current
msg = ("Die Einstellungen in der Fahrzeug-Vorlage beschränken den Strom auf "
msg = ("Die Einstellungen in dem Fahrzeug-Profil beschränken den Strom auf "
f"mindestens {required_current} A.")
else:
if phases == 1:
Expand All @@ -436,12 +436,12 @@ def check_min_max_current(
max_current = self.ev_template.data.max_current_multi_phases
if required_current > max_current:
required_current = max_current
msg = ("Die Einstellungen in der Fahrzeug-Vorlage beschränken den Strom auf "
msg = ("Die Einstellungen in dem Fahrzeug-Profil beschränken den Strom auf "
f"maximal {required_current} A.")
return required_current, msg

CURRENT_OUT_OF_NOMINAL_DIFFERENCE = (", da das Fahrzeug nicht mit der vorgegebenen Stromstärke +/- der erlaubten "
+ "Stromabweichung aus der Fahrzeug-Vorlage lädt.")
+ "Stromabweichung aus dem Fahrzeug-Profil lädt.")
ENOUGH_POWER = ", da ausreichend Leistung für mehrphasiges Laden zur Verfügung steht."
NOT_ENOUGH_POWER = ", da nicht ausreichend Leistung für mehrphasiges Laden zur Verfügung steht."

Expand Down Expand Up @@ -606,7 +606,7 @@ class SelectedPlan:


class ChargeTemplate:
""" Klasse der Lademodus-Vorlage
""" Klasse der Lade-Profile
"""
BUFFER = -1200 # nach mehr als 20 Min Überschreitung wird der Termin als verpasst angesehen

Expand Down
44 changes: 22 additions & 22 deletions packages/helpermodules/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def removeChargepoint(self, connection_id: str, payload: dict) -> None:
f'Ladepunkt mit ID \'{payload["data"]["id"]}\' gelöscht.', MessageType.SUCCESS)

def addChargepointTemplate(self, connection_id: str, payload: dict) -> None:
""" sendet das Topic, zu dem eine neue Ladepunkt-Vorlage erstellt werden soll.
""" sendet das Topic, zu dem ein neues Ladepunkt-Profil erstellt werden soll.
"""
new_id = self.max_id_chargepoint_template + 1
default = get_chargepoint_template_default()
Expand All @@ -265,11 +265,11 @@ def addChargepointTemplate(self, connection_id: str, payload: dict) -> None:
self.max_id_chargepoint_template)
pub_user_message(
payload, connection_id,
f'Neue Ladepunkt-Vorlage mit ID \'{new_id}\' hinzugefügt.',
f'Neues Ladepunkt-Profil mit ID \'{new_id}\' hinzugefügt.',
MessageType.SUCCESS)

def removeChargepointTemplate(self, connection_id: str, payload: dict) -> None:
""" löscht eine Ladepunkt-Vorlage.
""" löscht ein Ladepunkt-Profil.
"""
if self.max_id_chargepoint_template < payload["data"]["id"]:
pub_user_message(
Expand All @@ -279,10 +279,10 @@ def removeChargepointTemplate(self, connection_id: str, payload: dict) -> None:
if payload["data"]["id"] > 0:
ProcessBrokerBranch(f'chargepoint/template/{payload["data"]["id"]}/').remove_topics()
pub_user_message(payload, connection_id,
f'Ladepunkt-Vorlage mit ID \'{payload["data"]["id"]}\' gelöscht.',
f'Ladepunkt-Profil mit ID \'{payload["data"]["id"]}\' gelöscht.',
MessageType.SUCCESS)
else:
pub_user_message(payload, connection_id, "Ladepunkt-Vorlage mit ID 0 darf nicht gelöscht werden.",
pub_user_message(payload, connection_id, "Ladepunkt-Profil mit ID 0 darf nicht gelöscht werden.",
MessageType.ERROR)

def addAutolockPlan(self, connection_id: str, payload: dict) -> None:
Expand All @@ -296,7 +296,7 @@ def addAutolockPlan(self, connection_id: str, payload: dict) -> None:
Pub().pub("openWB/set/command/max_id/autolock_plan", new_id)
pub_user_message(
payload, connection_id,
f'Neuer Autolock-Plan mit ID \'{new_id}\' zu Template '
f'Neuer Autolock-Plan mit ID \'{new_id}\' zu Profil '
f'\'{payload["data"]["template"]}\' hinzugefügt.',
MessageType.SUCCESS)

Expand All @@ -314,12 +314,12 @@ def removeAutolockPlan(self, connection_id: str, payload: dict) -> None:
"")
pub_user_message(
payload, connection_id,
f'Autolock-Plan mit ID \'{payload["data"]["plan"]}\' zu Template '
f'Autolock-Plan mit ID \'{payload["data"]["plan"]}\' vom Profil '
f'\'{payload["data"]["template"]}\' gelöscht.',
MessageType.SUCCESS)

def addChargeTemplate(self, connection_id: str, payload: dict) -> None:
""" sendet das Topic, zu dem eine neue Lade-Vorlage erstellt werden soll.
""" sendet das Topic, zu dem ein neues Lade-Profil erstellt werden soll.
"""
new_id = self.max_id_charge_template + 1
charge_template_default = ev.get_charge_template_default()
Expand All @@ -328,11 +328,11 @@ def addChargeTemplate(self, connection_id: str, payload: dict) -> None:
self.max_id_charge_template = new_id
Pub().pub("openWB/set/command/max_id/charge_template", new_id)
pub_user_message(payload, connection_id,
f'Neues Lade-Template mit ID \'{new_id}\' hinzugefügt.',
f'Neues Lade-Profil mit ID \'{new_id}\' hinzugefügt.',
MessageType.SUCCESS)

def removeChargeTemplate(self, connection_id: str, payload: dict) -> None:
""" löscht eine Lade-Vorlage.
""" löscht ein Lade-Profil.
"""
if self.max_id_charge_template < payload["data"]["id"]:
pub_user_message(payload, connection_id, "Die ID ist größer als die maximal vergebene ID.",
Expand All @@ -341,10 +341,10 @@ def removeChargeTemplate(self, connection_id: str, payload: dict) -> None:
Pub().pub(f'openWB/vehicle/template/charge_template/{payload["data"]["id"]}', "")
pub_user_message(
payload, connection_id,
f'Lade-Template mit ID \'{payload["data"]["id"]}\' gelöscht.',
f'Lade-Profil mit ID \'{payload["data"]["id"]}\' gelöscht.',
MessageType.SUCCESS)
else:
pub_user_message(payload, connection_id, "Ladevorlage mit ID 0 darf nicht gelöscht werden.",
pub_user_message(payload, connection_id, "Lade-Profil mit ID 0 darf nicht gelöscht werden.",
MessageType.ERROR)

def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> None:
Expand All @@ -361,7 +361,7 @@ def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> No
"openWB/set/command/max_id/charge_template_scheduled_plan", new_id)
pub_user_message(
payload, connection_id,
f'Neues Zielladen-Template mit ID \'{new_id}\' zu Template '
f'Neuer Zielladen-Plan mit ID \'{new_id}\' zu Profil '
f'\'{payload["data"]["template"]}\' hinzugefügt.',
MessageType.SUCCESS)

Expand All @@ -379,7 +379,7 @@ def removeChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) ->
"")
pub_user_message(
payload, connection_id,
f'Zielladen-Template mit ID \'{payload["data"]["plan"]}\' zu Template '
f'Zielladen-Plan mit ID \'{payload["data"]["plan"]}\' von Profil '
f'{payload["data"]["template"]}\' gelöscht.',
MessageType.SUCCESS)

Expand All @@ -397,7 +397,7 @@ def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -
"openWB/set/command/max_id/charge_template_time_charging_plan", new_id)
pub_user_message(
payload, connection_id,
f'Neues Zeitladen-Template mit ID \'{new_id}\' zu Template '
f'Neuer Zeitladen-Plan mit ID \'{new_id}\' zu Profil '
f'{payload["data"]["template"]}\' hinzugefügt.', MessageType.SUCCESS)

def removeChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -> None:
Expand All @@ -412,7 +412,7 @@ def removeChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict
"")
pub_user_message(
payload, connection_id,
f'Zeitladen-Template mit ID \'{payload["data"]["plan"]}\' zu Template '
f'Zeitladen-Plan mit ID \'{payload["data"]["plan"]}\' zu Profil '
f'\'{payload["data"]["template"]}\' gelöscht.', MessageType.SUCCESS)

def addComponent(self, connection_id: str, payload: dict) -> None:
Expand Down Expand Up @@ -479,7 +479,7 @@ def removeComponent(self, connection_id: str, payload: dict) -> None:
f'Komponente mit ID \'{payload["data"]["id"]}\' gelöscht.', MessageType.SUCCESS)

def addEvTemplate(self, connection_id: str, payload: dict) -> None:
""" sendet das Topic, zu dem ein neues EV-Template erstellt werden soll.
""" sendet das Topic, zu dem ein neues Fahrzeug-Profil erstellt werden soll.
"""
new_id = self.max_id_ev_template + 1
ev_template_default = dataclass_utils.asdict(ev.EvTemplateData())
Expand All @@ -488,10 +488,10 @@ def addEvTemplate(self, connection_id: str, payload: dict) -> None:
Pub().pub("openWB/set/command/max_id/ev_template", new_id)
pub_user_message(
payload, connection_id,
f'Neues EV-Template mit ID \'{new_id}\' hinzugefügt.', MessageType.SUCCESS)
f'Neues Fahrzeug-Profil mit ID \'{new_id}\' hinzugefügt.', MessageType.SUCCESS)

def removeEvTemplate(self, connection_id: str, payload: dict) -> None:
""" löscht ein EV-Template.
""" löscht ein Fahrzeug-Profil.
"""
if self.max_id_ev_template < payload["data"]["id"]:
pub_user_message(payload, connection_id,
Expand All @@ -500,10 +500,10 @@ def removeEvTemplate(self, connection_id: str, payload: dict) -> None:
Pub().pub(f'openWB/vehicle/template/ev_template/{payload["data"]["id"]}', "")
pub_user_message(
payload, connection_id,
f'EV-Template mit ID \'{payload["data"]["id"]}\' gelöscht.', MessageType.SUCCESS)
f'Fahrzeug-Profil mit ID \'{payload["data"]["id"]}\' gelöscht.', MessageType.SUCCESS)
else:
pub_user_message(payload, connection_id,
"EV-Vorlage mit ID 0 darf nicht gelöscht werden.", MessageType.ERROR)
"Fahrzeug-Profil mit ID 0 darf nicht gelöscht werden.", MessageType.ERROR)

def addVehicle(self, connection_id: str, payload: dict) -> None:
""" sendet das Topic, zu dem ein neues Vehicle erstellt werden soll.
Expand All @@ -516,7 +516,7 @@ def addVehicle(self, connection_id: str, payload: dict) -> None:
Pub().pub(f"openWB/set/vehicle/{new_id}/soc_module/interval_config", dataclass_utils.asdict(IntervalConfig()))
self.max_id_vehicle = self.max_id_vehicle + 1
Pub().pub("openWB/set/command/max_id/vehicle", self.max_id_vehicle)
# Default-Mäßig werden die Templates 0 zugewiesen, wenn diese noch nicht existieren -> anlegen
# Default-Mäßig werden die Profile 0 zugewiesen, wenn diese noch nicht existieren -> anlegen
if self.max_id_charge_template == -1:
self.addChargeTemplate("addVehicle", {})
if self.max_id_ev_template == -1:
Expand Down
4 changes: 2 additions & 2 deletions packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _validate_value(self, msg: mqtt.MQTTMessage, data_type, ranges=[], collectio
if "ct"+str(index) in subdata.SubData.ev_charge_template_data:
template = dataclass_utils.asdict(copy.deepcopy(
subdata.SubData.ev_charge_template_data["ct"+str(index)].data))
# Wenn eine Einzeleinstellung empfangen wird, muss das gesamte Template veröffentlicht
# Wenn eine Einzeleinstellung empfangen wird, muss das gesamte Profil veröffentlicht
# werden (pub_json=True), allerdings ohne Pläne. Diese sind in einem Extra-Topic.
try:
template["chargemode"]["scheduled_charging"].pop("plans")
Expand Down Expand Up @@ -443,7 +443,7 @@ def process_vehicle_topic(self, msg: mqtt.MQTTMessage):
log.exception(f"Fehler im setdata-Modul: Topic {msg.topic}, Value: {msg.payload}")

def _subprocess_vehicle_chargemode_topic(self, msg: mqtt.MQTTMessage):
""" Handler für die EV-Chargemode-Template-Topics
""" Handler für die Lade-Profil-Topics
Parameters
----------
msg:
Expand Down
4 changes: 2 additions & 2 deletions packages/helpermodules/subdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def process_vehicle_charge_template_topic(self, var: Dict[str, ev.ChargeTemplate
var["ct"+index].data.chargemode.scheduled_charging.plans.pop(index_second)
except KeyError:
log.error("Es konnte kein Zielladen-Plan mit der ID " +
str(index_second)+" in der Ladevorlage "+str(index)+" gefunden werden.")
str(index_second)+" in dem Lade-Profil "+str(index)+" gefunden werden.")
else:
var["ct"+index].data.chargemode.scheduled_charging.plans[
index_second] = dataclass_from_dict(ev.ScheduledChargingPlan, decode_payload(msg.payload))
Expand All @@ -325,7 +325,7 @@ def process_vehicle_charge_template_topic(self, var: Dict[str, ev.ChargeTemplate
var["ct"+index].data.time_charging.plans.pop(index_second)
except KeyError:
log.error("Es konnte kein Zeitladen-Plan mit der ID " +
str(index_second)+" in der Ladevorlage "+str(index)+" gefunden werden.")
str(index_second)+" in dem Lade-Profil "+str(index)+" gefunden werden.")
else:
var["ct"+index].data.time_charging.plans[
index_second] = dataclass_from_dict(ev.TimeChargingPlan, decode_payload(msg.payload))
Expand Down
2 changes: 1 addition & 1 deletion packages/helpermodules/update_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
b'"power_module": {}}'),
'openWB/chargepoint/get/power': b'0',
'openWB/chargepoint/template/0': (b'{"autolock": {"active": false, "plans": {}, "wait_for_charging_end": false}, '
b'"name": "Standard Ladepunkt-Vorlage", "rfid_enabling": false, '
b'"name": "Standard Ladepunkt-Profil", "rfid_enabling": false, '
b'"valid_tags": [], "id": 0}'),
'openWB/optional/int_display/theme': b'"cards"'}

Expand Down

0 comments on commit b1c6d6b

Please sign in to comment.