Skip to content
Closed
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
49 changes: 3 additions & 46 deletions packages/control/ev.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from control.chargepoint.control_parameter import ControlParameter
from control.limiting_value import LimitingValue
from dataclass_utils.factories import empty_dict_factory, empty_list_factory
from helpermodules.abstract_plans import Limit, limit_factory, ScheduledChargingPlan, TimeChargingPlan
from helpermodules.abstract_plans import ScheduledChargingPlan, TimeChargingPlan
from helpermodules import timecheck
from helpermodules.constants import NO_ERROR
from modules.common.abstract_vehicle import VehicleUpdateData
Expand Down Expand Up @@ -73,7 +73,6 @@ class TimeCharging:
class InstantCharging:
current: int = 10
dc_current: float = 145
limit: Limit = field(default_factory=limit_factory)


@dataclass
Expand Down Expand Up @@ -115,22 +114,11 @@ def chargemode_factory() -> Chargemode:
return Chargemode()


@dataclass
class Et:
active: bool = False
max_price: float = 0.0002


def et_factory() -> Et:
return Et()


@dataclass
class ChargeTemplateData:
name: str = "Lade-Profil"
prio: bool = False
load_default: bool = False
et: Et = field(default_factory=et_factory)
time_charging: TimeCharging = field(default_factory=time_charging_factory)
chargemode: Chargemode = field(default_factory=chargemode_factory)

Expand Down Expand Up @@ -342,10 +330,7 @@ def get_required_current(self,
if control_parameter.imported_instant_charging is None:
control_parameter.imported_instant_charging = imported
used_amount = imported - control_parameter.imported_instant_charging
required_current, submode, message = self.charge_template.instant_charging(
self.data.get.soc,
used_amount,
charging_type)
required_current, submode, message = self.charge_template.instant_charging(charging_type)
elif self.charge_template.data.chargemode.selected == "pv_charging":
required_current, submode, message = self.charge_template.pv_charging(
self.data.get.soc, control_parameter.min_current, charging_type)
Expand Down Expand Up @@ -603,7 +588,6 @@ class ChargeTemplate:
"topic": ""})

BUFFER = -1200 # nach mehr als 20 Min Überschreitung wird der Termin als verpasst angesehen
CHARGING_PRICE_EXCEEDED = "Keine Ladung, da der aktuelle Strompreis über dem maximalen Strompreis liegt."

TIME_CHARGING_NO_PLAN_CONFIGURED = "Keine Ladung, da keine Zeitfenster für Zeitladen konfiguriert sind."
TIME_CHARGING_NO_PLAN_ACTIVE = "Keine Ladung, da kein Zeitfenster für Zeitladen aktiv ist."
Expand All @@ -622,9 +606,6 @@ def time_charging(self,
plan = timecheck.check_plans_timeframe(self.data.time_charging.plans)
if plan is not None:
current = plan.current if charging_type == ChargingType.AC.value else plan.dc_current
if self.data.et.active and data.data.optional_data.et_provider_available():
if not data.data.optional_data.et_price_lower_than_limit(self.data.et.max_price):
return 0, "stop", self.CHARGING_PRICE_EXCEEDED, plan.name
if plan.limit.selected == "none": # kein Limit konfiguriert, mit konfigurierter Stromstärke laden
return current, "time_charging", message, plan.name
elif plan.limit.selected == "soc": # SoC Limit konfiguriert
Expand Down Expand Up @@ -652,12 +633,7 @@ def time_charging(self,
log.exception("Fehler im ev-Modul "+str(self.ct_num))
return 0, "stop", "Keine Ladung, da da ein interner Fehler aufgetreten ist: "+traceback.format_exc(), None

INSTANT_CHARGING_SOC_REACHED = "Kein Sofortladen, da der Soc bereits erreicht wurde."
INSTANT_CHARGING_AMOUNT_REACHED = "Kein Sofortladen, da die Energiemenge bereits geladen wurde."

def instant_charging(self,
soc: Optional[float],
imported_instant_charging: float,
charging_type: str) -> Tuple[int, str, Optional[str]]:
""" prüft, ob die Lademengenbegrenzung erreicht wurde und setzt entsprechend den Ladestrom.
"""
Expand All @@ -668,26 +644,7 @@ def instant_charging(self,
current = instant_charging.current
else:
current = instant_charging.dc_current
if self.data.et.active and data.data.optional_data.et_provider_available():
if not data.data.optional_data.et_price_lower_than_limit(self.data.et.max_price):
return 0, "stop", self.CHARGING_PRICE_EXCEEDED
if instant_charging.limit.selected == "none":
return current, "instant_charging", message
elif instant_charging.limit.selected == "soc":
if soc:
if soc < instant_charging.limit.soc:
return current, "instant_charging", message
else:
return 0, "stop", self.INSTANT_CHARGING_SOC_REACHED
else:
return current, "instant_charging", message
elif instant_charging.limit.selected == "amount":
if imported_instant_charging < self.data.chargemode.instant_charging.limit.amount:
return current, "instant_charging", message
else:
return 0, "stop", self.INSTANT_CHARGING_AMOUNT_REACHED
else:
raise TypeError(f'{instant_charging.limit.selected} unbekanntes Sofortladen-Limit.')
return current, "instant_charging", message
except Exception:
log.exception("Fehler im ev-Modul "+str(self.ct_num))
return 0, "stop", "Keine Ladung, da da ein interner Fehler aufgetreten ist: "+traceback.format_exc()
Expand Down
10 changes: 0 additions & 10 deletions packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,6 @@ def _subprocess_vehicle_chargemode_topic(self, msg: mqtt.MQTTMessage):
self._validate_value(msg, int, [(6, 32)], pub_json=True)
elif "/chargemode/instant_charging/dc_current" in msg.topic:
self._validate_value(msg, float, [(4, 300)], pub_json=True)
elif "/chargemode/instant_charging/limit/selected" in msg.topic:
self._validate_value(msg, str, pub_json=True)
elif "/chargemode/instant_charging/limit/soc" in msg.topic:
self._validate_value(msg, int, [(0, 100)], pub_json=True)
elif "/chargemode/instant_charging/limit/amount" in msg.topic:
self._validate_value(msg, int, [(1000, float("inf"))], pub_json=True)
elif "/chargemode/pv_charging/feed_in_limit" in msg.topic:
self._validate_value(msg, bool, pub_json=True)
elif "/chargemode/pv_charging/min_current" in msg.topic:
Expand All @@ -483,10 +477,6 @@ def _subprocess_vehicle_chargemode_topic(self, msg: mqtt.MQTTMessage):
self._validate_value(msg, "json")
elif "/chargemode/scheduled_charging" in msg.topic:
self._validate_value(msg, "json", pub_json=True)
elif "/et/active" in msg.topic:
self._validate_value(msg, bool, pub_json=True)
elif "/et/max_price" in msg.topic:
self._validate_value(msg, float, pub_json=True)
elif "/time_charging/active" in msg.topic:
self._validate_value(msg, bool, pub_json=True)
elif "/time_charging/plans/" in msg.topic and "/active" in msg.topic:
Expand Down
15 changes: 14 additions & 1 deletion packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


class UpdateConfig:
DATASTORE_VERSION = 65
DATASTORE_VERSION = 66
valid_topic = [
"^openWB/bat/config/configured$",
"^openWB/bat/config/power_limit_mode$",
Expand Down Expand Up @@ -1839,3 +1839,16 @@ def upgrade_datastore_64(self) -> None:
'<a href="https://wb-solution.de/shop/">https://wb-solution.de/shop/</a>',
MessageType.INFO)
self.__update_topic("openWB/system/datastore_version", 65)

def upgrade_datastore_65(self) -> None:
def upgrade(topic: str, payload) -> Optional[dict]:
if re.search("openWB/vehicle/template/charge_template/[0-9]+", topic) is not None:
index = get_index(topic)
payload = decode_payload(payload)
if "et" in payload:
payload.pop("et")
if "limit" in payload["chargemode"]["instant_charging"]:
payload.pop("limit")
return {f"openWB/vehicle/template/charge_template/{index}": payload}
self._loop_all_received_topics(upgrade)
self.__update_topic("openWB/system/datastore_version", 66)
Original file line number Diff line number Diff line change
Expand Up @@ -507,128 +507,6 @@ export default {
"
/>
</i-form-group>
<i-form-group>
<i-form-label>Begrenzung</i-form-label>
<i-button-group block>
<i-button
:color="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'none'
? 'primary'
: ''
"
:active="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'none'
"
@click="
setChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
'none',
)
"
>
Keine
</i-button>
<i-button
:color="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'soc'
? 'primary'
: ''
"
:active="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'soc'
"
@click="
setChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
'soc',
)
"
>
EV-SoC
</i-button>
<i-button
:color="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'amount'
? 'primary'
: ''
"
:active="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'amount'
"
@click="
setChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
'amount',
)
"
>
Energie
</i-button>
</i-button-group>
</i-form-group>
<i-form-group
v-if="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'soc'
"
>
<i-form-label>Max. SoC</i-form-label>
<extended-number-input
unit="%"
:min="5"
:max="100"
:step="5"
:model-value="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).soc
"
@update:model-value="
setChargePointConnectedVehicleInstantChargingLimitSoc(
modalChargePointId,
$event,
)
"
/>
</i-form-group>
<i-form-group
v-if="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).selected == 'amount'
"
>
<i-form-label>Max. Energie</i-form-label>
<extended-number-input
unit="kWh"
:min="1"
:max="100"
:model-value="
mqttStore.getChargePointConnectedVehicleInstantChargingLimit(
modalChargePointId,
).amount / 1000
"
@update:model-value="
setChargePointConnectedVehicleInstantChargingLimitAmount(
modalChargePointId,
$event * 1000,
)
"
/>
</i-form-group>
</i-form>
</i-tab>
<i-tab name="tab-pv-charging">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,6 @@
unit="A"
/>
</ConfigItem>
<hr v-if="cp.instantChargeLimitMode != 'none'" />
<!-- Limit Mode -->
<ConfigItem title="Begrenzung" icon="fa-hand" :fullwidth="true">
<RadioInput
v-model="cp.instantChargeLimitMode"
:options="instantChargeLimitModes.map((e) => [e.name, e.id])"
/>
</ConfigItem>
<!-- Max SoC -->
<ConfigItem
v-if="cp.instantChargeLimitMode == 'soc'"
title="Maximaler SoC"
icon="fa-sliders"
:fullwidth="true"
>
<RangeInput
id="maxSoc"
v-model="cp.instantTargetSoc"
:min="0"
:max="100"
:step="1"
unit="%"
/>
</ConfigItem>

<!-- Max Energy -->
<ConfigItem
v-if="cp.instantChargeLimitMode == 'amount'"
title="Zu ladende Energie"
icon="fa-sliders"
:fullwidth="true"
>
<RangeInput
id="maxEnergy"
v-model="energyLimit"
:min="0"
:max="100"
:step="1"
unit="kWh"
/>
</ConfigItem>
</div>
</template>

Expand All @@ -61,7 +20,6 @@ import { computed } from 'vue'
import { chargePoints } from './model'
import ConfigItem from '../shared/ConfigItem.vue'
import RangeInput from '@/components/shared/RangeInput.vue'
import RadioInput from '@/components/shared/RadioInput.vue'

const props = defineProps<{
chargepointId: number
Expand All @@ -71,19 +29,8 @@ const cp = computed(() => {
return chargePoints[props.chargepointId]
})

const instantChargeLimitModes = [
{ name: 'keine', id: 'none' },
{ name: 'EV-SoC', id: 'soc' },
{ name: 'Energiemenge', id: 'amount' },
]
const energyLimit = computed({
get() {
return cp.value.instantMaxEnergy / 1000
},
set(limit: number) {
cp.value.instantMaxEnergy = limit * 1000
},
})


// methods
</script>

Expand Down
Loading
Loading