Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/control/bat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
import logging
from typing import List
from typing import List, Optional

from dataclass_utils.factories import currents_list_factory
from helpermodules.constants import NO_ERROR
Expand Down Expand Up @@ -41,7 +41,7 @@ def get_factory() -> Get:

@dataclass
class Set:
power_limit: float = field(default=None, metadata={"topic": "set/power_limit"})
power_limit: Optional[int] = field(default=None, metadata={"topic": "set/power_limit"})

Comment on lines 42 to 45

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

power_limit is annotated as int but the field default is None, so the type should be Optional[int] (and import Optional) to match actual runtime values and the AbstractBat.set_power_limit(self, power_limit: Optional[int]) contract.

Copilot uses AI. Check for mistakes.

def set_factory() -> Set:
Expand Down
8 changes: 4 additions & 4 deletions packages/control/bat_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def _set_bat_power_active_control(self, power):
# setze Entladeleistung als Bruchteil der möglichen Entladeleistung
else:
factor = min(power / max_discharge_power_total, 1)
power_limit = bat_component_data.get.max_discharge_power * factor
bat_component_data.get.state_str = f"Entladung mit {power_limit}W"
power_limit = int(bat_component_data.get.max_discharge_power * factor)
bat_component_data.get.state_str = f"Entladung mit {round(power_limit / 1000, 3)} kW"
log.debug(("Aktive Speichersteuerung: Entladung - "
f"Speicher (ID: {bat_component.component_config.id}) "
f"entlädt mit {power_limit} ({factor} x "
Expand All @@ -296,8 +296,8 @@ def _set_bat_power_active_control(self, power):
"befindet sich oberhalb maximal SoC - Speicher sperren."))
else:
factor = min(power / max_charge_power_total, 1)
power_limit = bat_component_data.get.max_charge_power * factor
bat_component_data.get.state_str = f"Ladung mit {power_limit}W "
power_limit = int(bat_component_data.get.max_charge_power * factor)
bat_component_data.get.state_str = f"Ladung mit {round(power_limit / 1000, 3)} kW "
log.debug(("Aktive Speichersteuerung: Ladung - "
f"Speicher (ID: {bat_component.component_config.id}) "
f"lädt mit {power_limit} ({factor} x {bat_component_data.get.max_charge_power})"))
Expand Down
Loading