mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-01-29 22:06:18 +00:00
ci(ruff): add bandit checks (#575)
Added bandit checks to continuous integration. Updated sources to pass bandit checks: - replaced asserts - added timeouts to requests - added checks for process command execution - changed to 127.0.0.1 as default IP address for EOS and EOSdash for security reasons Added a rudimentary check for outdated config files. BREAKING CHANGE: Default IP address for EOS and EOSdash changed to 127.0.0.1 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -121,7 +121,8 @@ class Battery(DeviceBase):
|
||||
|
||||
def _setup(self) -> None:
|
||||
"""Sets up the battery parameters based on configuration or provided parameters."""
|
||||
assert self.parameters is not None
|
||||
if self.parameters is None:
|
||||
raise ValueError(f"Parameters not set: {self.parameters}")
|
||||
self.capacity_wh = self.parameters.capacity_wh
|
||||
self.initial_soc_percentage = self.parameters.initial_soc_percentage
|
||||
self.charging_efficiency = self.parameters.charging_efficiency
|
||||
|
||||
@@ -170,7 +170,8 @@ class DevicesBase(DevicesStartEndMixin, PredictionMixin):
|
||||
def add_device(self, device: Optional["DeviceBase"]) -> None:
|
||||
if device is None:
|
||||
return
|
||||
assert device.device_id not in self.devices, f"{device.device_id} already registered"
|
||||
if device.device_id in self.devices:
|
||||
raise ValueError(f"{device.device_id} already registered")
|
||||
self.devices[device.device_id] = device
|
||||
|
||||
def remove_device(self, device: Type["DeviceBase"] | str) -> bool:
|
||||
|
||||
@@ -34,7 +34,8 @@ class HomeAppliance(DeviceBase):
|
||||
super().__init__(parameters)
|
||||
|
||||
def _setup(self) -> None:
|
||||
assert self.parameters is not None
|
||||
if self.parameters is None:
|
||||
raise ValueError(f"Parameters not set: {self.parameters}")
|
||||
self.load_curve = np.zeros(self.hours) # Initialize the load curve with zeros
|
||||
self.duration_h = self.parameters.duration_h
|
||||
self.consumption_wh = self.parameters.consumption_wh
|
||||
|
||||
@@ -28,7 +28,8 @@ class Inverter(DeviceBase):
|
||||
super().__init__(parameters)
|
||||
|
||||
def _setup(self) -> None:
|
||||
assert self.parameters is not None
|
||||
if self.parameters is None:
|
||||
raise ValueError(f"Parameters not set: {self.parameters}")
|
||||
if self.parameters.battery_id is None:
|
||||
# For the moment raise exception
|
||||
# TODO: Make battery configurable by config
|
||||
@@ -41,7 +42,8 @@ class Inverter(DeviceBase):
|
||||
) # Maximum power that the inverter can handle
|
||||
|
||||
def _post_setup(self) -> None:
|
||||
assert self.parameters is not None
|
||||
if self.parameters is None:
|
||||
raise ValueError(f"Parameters not set: {self.parameters}")
|
||||
self.battery = self.devices.get_device_by_id(self.parameters.battery_id)
|
||||
|
||||
def process_energy(
|
||||
|
||||
Reference in New Issue
Block a user