Skip to content

Commit 5f3308b

Browse files
LKuemmelBrett-S-OWB
andcommitted
Koala - Add Input dialog for editing scheduled and time plans (openWB#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 84961ea commit 5f3308b

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
@@ -485,13 +485,36 @@ def removeChargeTemplate(self, connection_id: str, payload: dict) -> None:
485485
pub_user_message(payload, connection_id, "Lade-Profil mit ID 0 darf nicht gelöscht werden.",
486486
MessageType.ERROR)
487487

488+
def _get_charge_template_by_source(self, payload: dict) -> ChargeTemplate:
489+
""" gibt das ChargeTemplate-Objekt zurück, je nachdem ob es sich um das persistente Ladeprofil oder das
490+
Ladeprofil des Ladepunkts handelt.
491+
"""
492+
if payload["data"]["changed_in_theme"]:
493+
charge_template = data.data.cp_data[f"cp{payload['data']['chargepoint']}"].data.set.charge_template
494+
else:
495+
charge_template = data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}']
496+
return charge_template
497+
498+
def _pub_charge_template_to_source(self, payload: dict, charge_template: ChargeTemplate) -> None:
499+
""" veröffentlicht das ChargeTemplate-Objekt, je nachdem ob es sich um das persistente Ladeprofil oder das
500+
Ladeprofil des Ladepunkts handelt.
501+
"""
502+
if payload["data"]["changed_in_theme"]:
503+
Pub().pub(
504+
f'openWB/set/chargepoint/{payload["data"]["chargepoint"]}/set/charge_template',
505+
dataclass_utils.asdict(charge_template.data))
506+
else:
507+
Pub().pub(
508+
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
509+
dataclass_utils.asdict(charge_template.data))
510+
488511
def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> None:
489512
""" sendet das Topic, zu dem ein neuer Zielladen-Plan erstellt werden soll.
490513
"""
514+
charge_template = self._get_charge_template_by_source(payload)
491515
# check if "payload" contains "data.copy"
492516
if "data" in payload and "copy" in payload["data"]:
493-
for plan in data.data.ev_charge_template_data[
494-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans:
517+
for plan in charge_template.data.chargemode.scheduled_charging.plans:
495518
if plan.id == payload["data"]["copy"]:
496519
new_charge_template_schedule_plan = copy.deepcopy(plan)
497520
break
@@ -500,12 +523,8 @@ def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> No
500523
new_charge_template_schedule_plan = ScheduledChargingPlan()
501524
new_id = self.max_id_charge_template_scheduled_plan + 1
502525
new_charge_template_schedule_plan.id = new_id
503-
data.data.ev_charge_template_data[
504-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans.append(
505-
new_charge_template_schedule_plan)
506-
Pub().pub(
507-
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
508-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
526+
charge_template.data.chargemode.scheduled_charging.plans.append(new_charge_template_schedule_plan)
527+
self._pub_charge_template_to_source(payload, charge_template)
509528
self.max_id_charge_template_scheduled_plan = new_id
510529
Pub().pub(
511530
"openWB/set/command/max_id/charge_template_scheduled_plan", new_id)
@@ -518,21 +537,17 @@ def addChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> No
518537
def removeChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) -> None:
519538
""" löscht einen Zielladen-Plan.
520539
"""
540+
charge_template = self._get_charge_template_by_source(payload)
521541
if self.max_id_charge_template_scheduled_plan < payload["data"]["plan"]:
522542
log.error(
523543
payload, connection_id,
524544
f'Die ID \'{payload["data"]["plan"]}\' ist größer als die maximal vergebene '
525545
f'ID \'{self.max_id_charge_template_scheduled_plan}\'.', MessageType.ERROR)
526-
for plan in data.data.ev_charge_template_data[
527-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans:
546+
for plan in charge_template.data.chargemode.scheduled_charging.plans:
528547
if plan.id == payload["data"]["plan"]:
529-
data.data.ev_charge_template_data[
530-
f'ct{payload["data"]["template"]}'].data.chargemode.scheduled_charging.plans.remove(
531-
plan)
548+
charge_template.data.chargemode.scheduled_charging.plans.remove(plan)
532549
break
533-
Pub().pub(
534-
f'openWB/vehicle/template/charge_template/{payload["data"]["template"]}',
535-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
550+
self._pub_charge_template_to_source(payload, charge_template)
536551
pub_user_message(
537552
payload, connection_id,
538553
f'Zielladen-Plan mit ID \'{payload["data"]["plan"]}\' von Profil '
@@ -542,9 +557,10 @@ def removeChargeTemplateSchedulePlan(self, connection_id: str, payload: dict) ->
542557
def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -> None:
543558
""" sendet das Topic, zu dem ein neuer Zeitladen-Plan erstellt werden soll.
544559
"""
560+
charge_template = self._get_charge_template_by_source(payload)
545561
# check if "payload" contains "data.copy"
546562
if "data" in payload and "copy" in payload["data"]:
547-
for plan in data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans:
563+
for plan in charge_template.data.time_charging.plans:
548564
if plan.id == payload["data"]["copy"]:
549565
new_time_charging_plan = copy.deepcopy(plan)
550566
break
@@ -553,11 +569,8 @@ def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -
553569
new_time_charging_plan = TimeChargingPlan()
554570
new_id = self.max_id_charge_template_time_charging_plan + 1
555571
new_time_charging_plan.id = new_id
556-
data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans.append(
557-
new_time_charging_plan)
558-
Pub().pub(
559-
f'openWB/set/vehicle/template/charge_template/{payload["data"]["template"]}',
560-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
572+
charge_template.data.time_charging.plans.append(new_time_charging_plan)
573+
self._pub_charge_template_to_source(payload, charge_template)
561574
self.max_id_charge_template_time_charging_plan = new_id
562575
Pub().pub(
563576
"openWB/set/command/max_id/charge_template_time_charging_plan", new_id)
@@ -569,17 +582,15 @@ def addChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -
569582
def removeChargeTemplateTimeChargingPlan(self, connection_id: str, payload: dict) -> None:
570583
""" löscht einen Zeitladen-Plan.
571584
"""
585+
charge_template = self._get_charge_template_by_source(payload)
572586
if self.max_id_charge_template_time_charging_plan < payload["data"]["plan"]:
573587
log.error(payload, connection_id, "Die ID ist größer als die maximal vergebene ID.",
574588
MessageType.ERROR)
575-
for plan in data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans:
589+
for plan in charge_template.data.time_charging.plans:
576590
if plan.id == payload["data"]["plan"]:
577-
data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data.time_charging.plans.remove(
578-
plan)
591+
charge_template.data.time_charging.plans.remove(plan)
579592
break
580-
Pub().pub(
581-
f'openWB/vehicle/template/charge_template/{payload["data"]["template"]}',
582-
dataclass_utils.asdict(data.data.ev_charge_template_data[f'ct{payload["data"]["template"]}'].data))
593+
self._pub_charge_template_to_source(payload, charge_template)
583594
pub_user_message(
584595
payload, connection_id,
585596
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)