Skip to content

Commit

Permalink
fix typo (#1941)
Browse files Browse the repository at this point in the history
  • Loading branch information
benderl authored Oct 11, 2024
1 parent e1b7217 commit 5363ed6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/control/bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Get:
fault_state: int = field(default=0, metadata={"topic": "get/fault_state"})
fault_str: str = field(default=NO_ERROR, metadata={"topic": "get/fault_str"})
power: float = field(default=0, metadata={"topic": "get/power"})
power_limit_controlable: bool = field(default=False, metadata={"topic": "get/power_limit_controlable"})
power_limit_controllable: bool = field(default=False, metadata={"topic": "get/power_limit_controllable"})


def get_factory() -> Get:
Expand Down
26 changes: 13 additions & 13 deletions packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def config_factory() -> Config:

@dataclass
class Get:
power_limit_controlable: bool = field(default=False, metadata={"topic": "get/power_limit_controlable"})
power_limit_controllable: bool = field(default=False, metadata={"topic": "get/power_limit_controllable"})
soc: float = field(default=0, metadata={"topic": "get/soc"})
daily_exported: float = field(default=0, metadata={"topic": "get/daily_exported"})
daily_imported: float = field(default=0, metadata={"topic": "get/daily_imported"})
Expand Down Expand Up @@ -194,7 +194,7 @@ def setup_bat(self):
try:
if self.data.config.configured is True:
if self.data.get.fault_state == 0:
self.set_power_limit_controlable()
self.set_power_limit_controllable()
self.get_power_limit()
self._get_charging_power_left()
log.info(f"{self.data.set.charging_power_left}W verbleibende Speicher-Leistung")
Expand Down Expand Up @@ -293,19 +293,19 @@ def power_for_bat_charging(self):
log.exception("Fehler im Bat-Modul")
return 0

def set_power_limit_controlable(self):
controlable_bat_components = get_controlable_bat_components()
if len(controlable_bat_components) > 0:
self.data.get.power_limit_controlable = True
for bat in controlable_bat_components:
data.data.bat_data[f"bat{bat.component_config.id}"].data.get.power_limit_controlable = True
def set_power_limit_controllable(self):
controllable_bat_components = get_controllable_bat_components()
if len(controllable_bat_components) > 0:
self.data.get.power_limit_controllable = True
for bat in controllable_bat_components:
data.data.bat_data[f"bat{bat.component_config.id}"].data.get.power_limit_controllable = True
else:
self.data.get.power_limit_controlable = False
self.data.get.power_limit_controllable = False

def get_power_limit(self):
if (self.data.config.power_limit_mode != BatPowerLimitMode.NO_LIMIT.value
and len(get_chargepoints_by_chargemodes(CONSIDERED_CHARGE_MODES_ADDITIONAL_CURRENT)) > 0 and
self.data.get.power_limit_controlable and
self.data.get.power_limit_controllable and
# Nur wenn kein Überschuss im System ist, Speicherleistung begrenzen.
self.data.get.power <= 0 and
data.data.counter_all_data.get_evu_counter().data.get.power >= 0):
Expand All @@ -319,7 +319,7 @@ def get_power_limit(self):
if len(get_chargepoints_by_chargemodes(CONSIDERED_CHARGE_MODES_ADDITIONAL_CURRENT)) == 0:
log.debug("Speicher-Leistung nicht begrenzen, "
"da keine Ladepunkte in einem Lademodus mit Netzbezug sind.")
elif self.data.get.power_limit_controlable is False:
elif self.data.get.power_limit_controllable is False:
log.debug("Speicher-Leistung nicht begrenzen, da keine regelbaren Speicher vorhanden sind.")
elif self.data.get.power > 0:
log.debug("Speicher-Leistung nicht begrenzen, da kein Speicher entladen wird.")
Expand All @@ -328,7 +328,7 @@ def get_power_limit(self):
else:
log.debug("Speicher-Leistung nicht begrenzen.")
remaining_power_limit = self.data.set.power_limit
for bat_component in get_controlable_bat_components():
for bat_component in get_controllable_bat_components():
if self.data.set.power_limit is None:
power_limit = None
else:
Expand All @@ -340,7 +340,7 @@ def get_power_limit(self):
data.data.bat_data[f"bat{bat_component.component_config.id}"].data.set.power_limit = power_limit


def get_controlable_bat_components() -> List:
def get_controllable_bat_components() -> List:
bat_components = []
for value in data.data.system_data.values():
if isinstance(value, AbstractDevice):
Expand Down
10 changes: 5 additions & 5 deletions packages/control/bat_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PowerLimitParams:
expected_power_limit_bat: Optional[float]
power_limit_mode: str = BatPowerLimitMode.NO_LIMIT.value
cps: List[Chargepoint] = field(default_factory=default_chargepoint_factory)
power_limit_controlable: bool = True
power_limit_controllable: bool = True
bat_power: float = -10
evu_power: float = 200

Expand All @@ -184,7 +184,7 @@ class PowerLimitParams:
PowerLimitParams("keine Begrenzung", None),
PowerLimitParams("Begrenzung immer, keine LP im Sofortladen", None, cps=[],
power_limit_mode=BatPowerLimitMode.LIMIT_STOP.value),
PowerLimitParams("Begrenzung immer, Speicher nicht regelbar", None, power_limit_controlable=False,
PowerLimitParams("Begrenzung immer, Speicher nicht regelbar", None, power_limit_controllable=False,
power_limit_mode=BatPowerLimitMode.LIMIT_STOP.value),
PowerLimitParams("Begrenzung immer, Speicher lädt", None, bat_power=100,
power_limit_mode=BatPowerLimitMode.LIMIT_STOP.value),
Expand All @@ -200,7 +200,7 @@ class PowerLimitParams:
def test_get_power_limit(params: PowerLimitParams, data_, monkeypatch):
b_all = BatAll()
b_all.data.config.power_limit_mode = params.power_limit_mode
b_all.data.get.power_limit_controlable = params.power_limit_controlable
b_all.data.get.power_limit_controllable = params.power_limit_controllable
b_all.data.get.power = params.bat_power
data.data.counter_all_data = hierarchy_standard()
data.data.counter_all_data.data.set.home_consumption = 456
Expand All @@ -211,8 +211,8 @@ def test_get_power_limit(params: PowerLimitParams, data_, monkeypatch):
monkeypatch.setattr(bat_all, "get_chargepoints_by_chargemodes", get_chargepoints_by_chargemodes_mock)
get_evu_counter_mock = Mock(return_value=data.data.counter_data["counter0"])
monkeypatch.setattr(data.data.counter_all_data, "get_evu_counter", get_evu_counter_mock)
get_controlable_bat_components_mock = Mock(return_value=[MqttBat(MqttBatSetup(id=2))])
monkeypatch.setattr(bat_all, "get_controlable_bat_components", get_controlable_bat_components_mock)
get_controllable_bat_components_mock = Mock(return_value=[MqttBat(MqttBatSetup(id=2))])
monkeypatch.setattr(bat_all, "get_controllable_bat_components", get_controllable_bat_components_mock)

data.data.bat_all_data.get_power_limit()

Expand Down
4 changes: 2 additions & 2 deletions packages/control/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import threading
from typing import List

from control.bat_all import get_controlable_bat_components
from control.bat_all import get_controllable_bat_components
from control.chargelog import chargelog
from control.chargepoint import chargepoint
from control import data
Expand Down Expand Up @@ -60,7 +60,7 @@ def process_algorithm_results(self) -> None:
modules_threads.append(self._start_charging(cp))
except Exception:
log.exception("Fehler im Process-Modul für Ladepunkt "+str(cp))
for bat_component in get_controlable_bat_components():
for bat_component in get_controllable_bat_components():
modules_threads.append(
threading.Thread(
target=bat_component.set_power_limit,
Expand Down
4 changes: 2 additions & 2 deletions packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def process_bat_topic(self, msg: mqtt.MQTTMessage):
"""
try:
if ("openWB/set/bat/config/configured" in msg.topic or
"openWB/set/bat/get/power_limit_controlable" in msg.topic or
"openWB/set/bat/get/power_limit_controllable" in msg.topic or
"openWB/set/bat/set/regulate_up" in msg.topic):
self._validate_value(msg, bool)
elif "openWB/set/bat/set/charging_power_left" in msg.topic:
Expand Down Expand Up @@ -739,7 +739,7 @@ def process_bat_topic(self, msg: mqtt.MQTTMessage):
self._validate_value(msg, int, [(0, 2)])
elif "/get/fault_str" in msg.topic:
self._validate_value(msg, str)
elif "/set/power_limit_controlable" in msg.topic:
elif "/set/power_limit_controllable" in msg.topic:
self._validate_value(msg, bool)
elif "/set/power_limit" in msg.topic:
self._validate_value(msg, float)
Expand Down
4 changes: 2 additions & 2 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UpdateConfig:
"^openWB/bat/set/regulate_up$",
"^openWB/bat/get/fault_state$",
"^openWB/bat/get/fault_str$",
"^openWB/bat/get/power_limit_controlable$",
"^openWB/bat/get/power_limit_controllable$",
"^openWB/bat/get/soc$",
"^openWB/bat/get/power$",
"^openWB/bat/get/imported$",
Expand All @@ -72,7 +72,7 @@ class UpdateConfig:
"^openWB/bat/[0-9]+/get/daily_imported$",
"^openWB/bat/[0-9]+/get/fault_state$",
"^openWB/bat/[0-9]+/get/fault_str$",
"^openWB/bat/[0-9]+/get/power_limit_controlable$",
"^openWB/bat/[0-9]+/get/power_limit_controllable$",
"^openWB/bat/[0-9]+/set/power_limit$",

"^openWB/chargepoint/get/power$",
Expand Down

0 comments on commit 5363ed6

Please sign in to comment.