Skip to content

Commit 0bec238

Browse files
committed
fix copilot findings
1 parent 7564229 commit 0bec238

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/control/optional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ def remove(price_data: Dict, last_active_timestamp: int = 0) -> Dict:
150150
first_timestamp = (max([timestamp for timestamp in price_data.keys()
151151
if float(timestamp) <= now], default=0))
152152
return {int(timestamp): price for timestamp, price in price_data.items()
153-
if (timestamp) >= first_timestamp and
153+
if int(timestamp) >= int(first_timestamp) and
154154
(int(timestamp) <= last_active_timestamp if last_active_timestamp > 0 else True)}
155155

156156
try:
157157
if self.data.electricity_pricing.configured:
158158
ep = self.data.electricity_pricing
159159
# prices lists are updated in optional_data via mqtt listener
160-
if len(ep.get.prices) >= 0:
160+
if len(ep.get.prices) > 0:
161161
Pub().pub(f"{MQTT_PREFIX}/get/prices", remove(ep.get.prices))
162162
if self._flexible_tariff_module:
163163
Pub().pub(f"{MQTT_PREFIX}/flexible_tariff/get/prices", remove(ep.flexible_tariff.get.prices))
@@ -171,7 +171,7 @@ def remove(price_data: Dict, last_active_timestamp: int = 0) -> Dict:
171171

172172
def __get_current_timeslot_start(self) -> int:
173173
timestamp = self.__get_first_entry()[0]
174-
return float(timestamp)
174+
return int(timestamp)
175175

176176
def ep_get_current_price(self) -> float:
177177
if self.data.electricity_pricing.configured:

packages/modules/common/configurable_tariff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __update_et_provider_data(self) -> tuple[TariffState, int]:
6464
tariff_state = self._remove_outdated_prices(tariff_state, timeslot_length_seconds)
6565
return tariff_state, timeslot_length_seconds
6666

67-
def __calculate_next_query_time(self) -> float:
67+
def __calculate_next_query_time(self) -> None:
6868
now = datetime.now()
6969
current_hour = now.hour + 1 # next full hour
7070
log.debug(f"Aktuelle Tarif Update Stunde: {current_hour} Uhr."

packages/modules/common/store/_tariff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def __reduce_prices(prices: Dict[str, float]) -> Dict[int, float]:
7373
def __get_default_grid_fee_price(prices: Dict[str, float]) -> float:
7474
if (hasattr(data.data.optional_data.grid_fee_module.config, "default_price") and
7575
data.data.optional_data.grid_fee_module.config.default_price is not None):
76-
print("Using default grid fee price from configuration: " +
77-
f"{data.data.optional_data.grid_fee_module.config.default_price}")
76+
log.debug("Using default grid fee price from configuration: " +
77+
f"{data.data.optional_data.grid_fee_module.config.default_price}")
7878
return data.data.optional_data.grid_fee_module.config.default_price
7979
else:
8080
# Fallback: Median der vorhandenen Netzentgelte wird
@@ -87,7 +87,7 @@ def __get_default_grid_fee_price(prices: Dict[str, float]) -> float:
8787
def __normalize_grid_fee_prices(grid_fee_prices: Dict[int, float], max_timestamp: int) -> Dict[int, float]:
8888
'''
8989
Normalisiert die Netzentgelte.
90-
Dies ist notwendig, da Nettzentgelte die Preisen einiger Stromanbieter
90+
Dies ist notwendig, da die Preise einiger Stromanbieter
9191
bereits ein festes Netzentgeld enthalten.
9292
'''
9393
grid_fee_prices = __reduce_prices(grid_fee_prices)
@@ -97,7 +97,7 @@ def __normalize_grid_fee_prices(grid_fee_prices: Dict[int, float], max_timestamp
9797
and data.data.optional_data.flexible_tariff_module.config.includes_grid_fee is False):
9898
return grid_fee_prices
9999
else:
100-
# Bei flexiblen Tarifen, die das Netzentgeln _nicht_ enthalten,
100+
# Bei flexiblen Tarifen, die das Netzentgelt _nicht_ enthalten,
101101
# muss "includes_grid_fee" explizit auf False gesetzt werden.
102102
return {int(float(k)): v - __get_default_grid_fee_price(grid_fee_prices)
103103
for k, v in grid_fee_prices.items()}

packages/modules/common/store/_tariff_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def mock_data() -> None:
114114
),
115115
pytest.param(
116116
{DEFAULT_START_TIMESTAMP + step * 900: 10 for step in range(5)},
117-
{DEFAULT_START_TIMESTAMP + step * 900: 14 for step in range(5)}, # nedian 14
117+
{DEFAULT_START_TIMESTAMP + step * 900: 14 for step in range(5)}, # median 14
118118
True,
119119
10, # default_grid_fee_price overrides median grid fee price of 14
120120
{

packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def _fetch_price_for_time_slot(config: FixedHoursTariffConfiguration,
5959
return config.default_price
6060

6161

62-
def _calculate_price_timeslots(config: FixedHoursTariffConfiguration) -> int:
62+
def _calculate_price_timeslots(config: FixedHoursTariffConfiguration) -> TariffState:
6363
current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
6464
prices: Dict[str, float] = {}
6565
# 36 hours to cover the next day and the current day,
66-
# this ensures enough values in prises list when used as grid fee adjustment for flexible tariffs
67-
# that might provide prices untill midnight next day.
66+
# this ensures enough values in prices list when used as grid fee adjustment for flexible tariffs
67+
# that might provide prices until midnight next day.
6868
for i in range(36):
6969
for j in range(4): # get prices for quarter hours
7070
time_slot = current_hour + datetime.timedelta(hours=i, minutes=j * 15)

0 commit comments

Comments
 (0)