Rename settings variables (remove prefixes)

This commit is contained in:
Dominique Lasserre
2025-01-18 14:26:34 +01:00
parent 1e1bac9fdb
commit 3257dac92b
58 changed files with 867 additions and 918 deletions

View File

@@ -51,16 +51,16 @@ class DevicesStartEndMixin(ConfigMixin, EnergyManagementSystemMixin):
@computed_field # type: ignore[prop-decorator]
@property
def end_datetime(self) -> Optional[DateTime]:
"""Compute the end datetime based on the `start_datetime` and `prediction_hours`.
"""Compute the end datetime based on the `start_datetime` and `hours`.
Ajusts the calculated end time if DST transitions occur within the prediction window.
Returns:
Optional[DateTime]: The calculated end datetime, or `None` if inputs are missing.
"""
if self.ems.start_datetime and self.config.prediction.prediction_hours:
if self.ems.start_datetime and self.config.prediction.hours:
end_datetime = self.ems.start_datetime + to_duration(
f"{self.config.prediction.prediction_hours} hours"
f"{self.config.prediction.hours} hours"
)
dst_change = end_datetime.offset_hours - self.ems.start_datetime.offset_hours
logger.debug(

View File

@@ -18,9 +18,9 @@ class Heatpump:
COP_COEFFICIENT = 0.1
"""COP increase per degree"""
def __init__(self, max_heat_output: int, prediction_hours: int):
def __init__(self, max_heat_output: int, hours: int):
self.max_heat_output = max_heat_output
self.prediction_hours = prediction_hours
self.hours = hours
self.log = logging.getLogger(__name__)
def __check_outside_temperature_range__(self, temp_celsius: float) -> bool:
@@ -117,9 +117,9 @@ class Heatpump:
"""Simulate power data for 24 hours based on provided temperatures."""
power_data: List[float] = []
if len(temperatures) != self.prediction_hours:
if len(temperatures) != self.hours:
raise ValueError(
f"The temperature array must contain exactly {self.prediction_hours} entries, "
f"The temperature array must contain exactly {self.hours} entries, "
"one for each hour of the day."
)

View File

@@ -14,7 +14,7 @@ class InverterParameters(DeviceParameters):
device_id: str = Field(description="ID of inverter", examples=["inverter1"])
max_power_wh: float = Field(gt=0, examples=[10000])
battery: Optional[str] = Field(
battery_id: Optional[str] = Field(
default=None, description="ID of battery", examples=[None, "battery1"]
)
@@ -29,7 +29,7 @@ class Inverter(DeviceBase):
def _setup(self) -> None:
assert self.parameters is not None
if self.parameters.battery is None:
if self.parameters.battery_id is None:
# For the moment raise exception
# TODO: Make battery configurable by config
error_msg = "Battery for PV inverter is mandatory."
@@ -42,7 +42,7 @@ class Inverter(DeviceBase):
def _post_setup(self) -> None:
assert self.parameters is not None
self.battery = self.devices.get_device_by_id(self.parameters.battery)
self.battery = self.devices.get_device_by_id(self.parameters.battery_id)
def process_energy(
self, generation: float, consumption: float, hour: int