Skip to content

Commit

Permalink
🐛 Fix one-line conditional
Browse files Browse the repository at this point in the history
matching for 'not None' instead of positive value 🙈
  • Loading branch information
azogue committed May 29, 2023
1 parent f188bda commit e4270da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [v4.2.1](https://github.com/azogue/aiopvpc/tree/v4.2.1) - Fix injection price sensor attributes (2) (2023-05-29)

[Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.2.0...v4.2.1)

- 🐛 Fix one-line conditional matching for 'not None' instead of positive value 🙈
- ✅ tests: Add unit test for price sensor attributes

## [v4.2.0](https://github.com/azogue/aiopvpc/tree/v4.2.0) - Fix injection price sensor attributes (2023-05-29)

[Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.1.0...v4.2.0)
Expand Down
8 changes: 4 additions & 4 deletions aiopvpc/prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def _make_price_stats_attributes(
except ZeroDivisionError: # pragma: no cover
pass
attributes["max_price"] = max_price
best_price_at = next(iter(prices_sorted)).astimezone(timezone).hour
worst_price_at = next(iter(reversed(prices_sorted))).astimezone(timezone).hour
attributes["max_price_at"] = worst_price_at if sign_is_best else best_price_at
first_price_at = next(iter(prices_sorted)).astimezone(timezone).hour
last_price_at = next(iter(reversed(prices_sorted))).astimezone(timezone).hour
attributes["max_price_at"] = last_price_at if sign_is_best == 1 else first_price_at
attributes["min_price"] = min_price
attributes["min_price_at"] = best_price_at if sign_is_best else worst_price_at
attributes["min_price_at"] = first_price_at if sign_is_best == 1 else last_price_at
attributes["next_best_at"] = [
ts.astimezone(timezone).hour for ts in prices_sorted.keys() if ts >= utc_time
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ markers = [

[tool.poetry]
name = "aiopvpc"
version = "4.2.0"
version = "4.2.1"
description = "Retrieval of Spanish Electricity hourly prices (PVPC)"
authors = ["Eugenio Panadero <eugenio.panadero@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit e4270da

Please sign in to comment.