Skip to content

Commit d97205c

Browse files
Koala - Add Input dialog for editing scheduled and time plans (#2895)
* Add scheduled details component * Add / remove scheduled charging plan - details as dialog * Add time plan details - adjust backend command * Backend command * Add DC charging inputs * Display bidi settings in scheduled plan based on vehicle profile bidi enabled * Fix DC power values for scheduled and time planes * Close plan dialog upon plan deletion * Plan energy amount watts to kilowatts * Formatting fixes * Charging current title AC or DC * Formatting fix * Change add plan button outlined to filled * Formatting Delete plan button * Add kW label to DC power input field * Format input fields * Format input toggles --------- Co-authored-by: BrettS <brett.scott@openwb.de>
1 parent 5f70d0c commit d97205c

9 files changed

Lines changed: 1421 additions & 51 deletions

packages/helpermodules/command.py

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from control.chargepoint import chargepoint
1717
from control.chargepoint.chargepoint_template import get_chargepoint_template_default
1818

19-
from control.ev.charge_template import get_new_charge_template
19+
from control.ev.charge_template import ChargeTemplate, get_new_charge_template
2020
from control.ev.ev_template import EvTemplateData
2121
from helpermodules import pub
2222
from helpermodules.abstract_plans import AutolockPlan, ScheduledChargingPlan, TimeChargingPlan
@@ -488,13 +488,36 @@ def removeChargeTemplate(self, connection_id: str, payload: dict) -> None:
488488
pub_user_message(payload, connection_id, "Lade-Profil mit ID 0 darf nicht gelöscht werden.",
489489
MessageType.ERROR)
490490

491+
def _get_charge_template_by_source(self, payload: dict) -> ChargeTemplate:
492+
""" gibt das ChargeTemplate-Objekt zurück, je nachdem ob es sich um das persistente Ladeprofil oder das
493+
Ladeprofil des Ladepunkts handelt.
494+
"""
495+
if payload["data"]["changed_in_theme"]:
496+
charge_template = data.data.cp_data[f"cp{payload['data']['chargepoint']}"].data.set.charge_template
497+
else:
498+
charge_template = data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}']
499+
return charge_template
500+
501+
def _pub_charge_template_to_source(self, payload: dict, charge_template: ChargeTemplate) -> None:
502+
""" veröffentlicht das ChargeTemplate-Objekt, je nachdem ob es sich um das persistente Ladeprofil oder das
503+
Ladeprofil des Ladepunkts handelt.
504+
"""
505+
if payload["data"]["changed_in_theme"]:
506+
Pub().pub(
507+
f'openWB/set/chargepoint/{payload["data"]["chargepoint"]}/set/charge_template',
508+
dataclass_utils.asdict(charge_template.data))
509+
else:
510+
Pub().pub(
511+
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
512+
dataclass_utils.asdict(charge_template.data))
513+
491514
def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> None:
492515
""" sendet das Topic, zu dem ein neuer Zielladen-Plan erstellt werden soll.
493516
"""
517+
charge_template = self._get_charge_template_by_source(payload)
494518
# check if "payload" contains "data.copy"
495519
if "data" in payload and "copy" in payload["data"]:
496-
for plan in data.data.ev_charge_template_data[
497-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans:
520+
for plan in charge_template.data.chargemode.scheduled_charging.plans:
498521
if plan.id == payload["data"]["copy"]:
499522
new_charge_template_schedule_plan = copy.deepcopy(plan)
500523
break
@@ -503,12 +526,8 @@ def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> No
503526
new_charge_template_schedule_plan = ScheduledChargingPlan()
504527
new_id = self.max_id_charge_template_scheduled_plan + 1
505528
new_charge_template_schedule_plan.id = new_id
506-
data.data.ev_charge_template_data[
507-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans.append(
508-
new_charge_template_schedule_plan)
509-
Pub().pub(
510-
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
511-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
529+
charge_template.data.chargemode.scheduled_charging.plans.append(new_charge_template_schedule_plan)
530+
self._pub_charge_template_to_source(payload, charge_template)
512531
self.max_id_charge_template_scheduled_plan = new_id
513532
Pub().pub(
514533
"openWB/set/command/max_id/charge_template_scheduled_plan", new_id)
@@ -521,21 +540,17 @@ def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> No
521540
def removeChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> None:
522541
""" löscht einen Zielladen-Plan.
523542
"""
543+
charge_template = self._get_charge_template_by_source(payload)
524544
if self.max_id_charge_template_scheduled_plan < payload["data"]["plan"]:
525545
log.error(
526546
payload, connection_id,
527547
f'Die ID \'{payload["data"]["plan"]}\' ist größer als die maximal vergebene '
528548
f'ID \'{self.max_id_charge_template_scheduled_plan}\'.', MessageType.ERROR)
529-
for plan in data.data.ev_charge_template_data[
530-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans:
549+
for plan in charge_template.data.chargemode.scheduled_charging.plans:
531550
if plan.id == payload["data"]["plan"]:
532-
data.data.ev_charge_template_data[
533-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans.remove(
534-
plan)
551+
charge_template.data.chargemode.scheduled_charging.plans.remove(plan)
535552
break
536-
Pub().pub(
537-
f'openWB/vehicle/template/charge_template/{payload["data"]["template"]}',
538-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
553+
self._pub_charge_template_to_source(payload, charge_template)
539554
pub_user_message(
540555
payload, connection_id,
541556
f'Zielladen-Plan mit ID \'{payload["data"]["plan"]}\' von Profil '
@@ -545,9 +560,10 @@ def removeChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) ->
545560
def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -> None:
546561
""" sendet das Topic, zu dem ein neuer Zeitladen-Plan erstellt werden soll.
547562
"""
563+
charge_template = self._get_charge_template_by_source(payload)
548564
# check if "payload" contains "data.copy"
549565
if "data" in payload and "copy" in payload["data"]:
550-
for plan in data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans:
566+
for plan in charge_template.data.time_charging.plans:
551567
if plan.id == payload["data"]["copy"]:
552568
new_time_charging_plan = copy.deepcopy(plan)
553569
break
@@ -556,11 +572,8 @@ def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -
556572
new_time_charging_plan = TimeChargingPlan()
557573
new_id = self.max_id_charge_template_time_charging_plan + 1
558574
new_time_charging_plan.id = new_id
559-
data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans.append(
560-
new_time_charging_plan)
561-
Pub().pub(
562-
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
563-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
575+
charge_template.data.time_charging.plans.append(new_time_charging_plan)
576+
self._pub_charge_template_to_source(payload, charge_template)
564577
self.max_id_charge_template_time_charging_plan = new_id
565578
Pub().pub(
566579
"openWB/set/command/max_id/charge_template_time_charging_plan", new_id)
@@ -572,17 +585,15 @@ def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -
572585
def removeChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -> None:
573586
""" löscht einen Zeitladen-Plan.
574587
"""
588+
charge_template = self._get_charge_template_by_source(payload)
575589
if self.max_id_charge_template_time_charging_plan < payload["data"]["plan"]:
576590
log.error(payload, connection_id, "Die ID ist größer als die maximal vergebene ID.",
577591
MessageType.ERROR)
578-
for plan in data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans:
592+
for plan in charge_template.data.time_charging.plans:
579593
if plan.id == payload["data"]["plan"]:
580-
data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans.remove(
581-
plan)
594+
charge_template.data.time_charging.plans.remove(plan)
582595
break
583-
Pub().pub(
584-
f'openWB/vehicle/template/charge_template/{payload["data"]["template"]}',
585-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
596+
self._pub_charge_template_to_source(payload, charge_template)
586597
pub_user_message(
587598
payload, connection_id,
588599
f'Zeitladen-Plan mit ID \'{payload["data"]["plan"]}\' zu Profil '

packages/modules/web_themes/koala/source/src/components/ChargePointScheduledPlanButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
align="center"
55
class="cursor-pointer"
66
:color="planActive.value ? 'positive' : 'negative'"
7-
@click="planActive.value = !planActive.value"
7+
@click="$emit('editPlan', plan)"
88
>
99
<div class="column">
1010
<div class="plan-name">{{ plan.name }}</div>

0 commit comments

Comments
 (0)