aiopvpc-ng 5.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aiopvpc-ng might be problematic. Click here for more details.

Files changed (42) hide show
  1. aiopvpc_ng-5.0.0/.github/workflows/main.yml +59 -0
  2. aiopvpc_ng-5.0.0/.github/workflows/run_tests.yml +33 -0
  3. aiopvpc_ng-5.0.0/.gitignore +103 -0
  4. aiopvpc_ng-5.0.0/.pre-commit-config.yaml +37 -0
  5. aiopvpc_ng-5.0.0/CHANGELOG.md +249 -0
  6. aiopvpc_ng-5.0.0/LICENSE +21 -0
  7. aiopvpc_ng-5.0.0/PKG-INFO +54 -0
  8. aiopvpc_ng-5.0.0/README.md +39 -0
  9. aiopvpc_ng-5.0.0/aiopvpc_ng/__init__.py +14 -0
  10. aiopvpc_ng-5.0.0/aiopvpc_ng/const.py +112 -0
  11. aiopvpc_ng-5.0.0/aiopvpc_ng/ha_helpers.py +51 -0
  12. aiopvpc_ng-5.0.0/aiopvpc_ng/parser.py +162 -0
  13. aiopvpc_ng-5.0.0/aiopvpc_ng/prices.py +140 -0
  14. aiopvpc_ng-5.0.0/aiopvpc_ng/pvpc_data.py +427 -0
  15. aiopvpc_ng-5.0.0/aiopvpc_ng/pvpc_tariff.py +53 -0
  16. aiopvpc_ng-5.0.0/aiopvpc_ng/utils.py +14 -0
  17. aiopvpc_ng-5.0.0/pyproject.toml +75 -0
  18. aiopvpc_ng-5.0.0/tests/__init__.py +1 -0
  19. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1001_2021_06_01.json +1007 -0
  20. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1001_2021_10_30.json +1007 -0
  21. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1001_2021_10_31.json +1047 -0
  22. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1001_2024_03_09.json +1007 -0
  23. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_10211_2021_10_30.json +223 -0
  24. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_10211_2021_10_31.json +231 -0
  25. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_10211_2024_03_09.json +223 -0
  26. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1739_2021_10_30.json +223 -0
  27. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1739_2021_10_31.json +231 -0
  28. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1739_2024_03_09.json +223 -0
  29. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_1900_2024_03_09.json +1007 -0
  30. aiopvpc_ng-5.0.0/tests/api_examples/PRICES_ESIOS_2108_2024_03_09.json +1007 -0
  31. aiopvpc_ng-5.0.0/tests/api_examples/PVPC_CURV_DD_2021_06_01.json +604 -0
  32. aiopvpc_ng-5.0.0/tests/api_examples/PVPC_CURV_DD_2021_10_30.json +604 -0
  33. aiopvpc_ng-5.0.0/tests/api_examples/PVPC_CURV_DD_2021_10_31.json +629 -0
  34. aiopvpc_ng-5.0.0/tests/api_examples/PVPC_CURV_DD_2022_03_27.json +579 -0
  35. aiopvpc_ng-5.0.0/tests/conftest.py +169 -0
  36. aiopvpc_ng-5.0.0/tests/test_ha_helpers.py +131 -0
  37. aiopvpc_ng-5.0.0/tests/test_pvpc.py +184 -0
  38. aiopvpc_ng-5.0.0/tests/test_pvpc_parsing.py +149 -0
  39. aiopvpc_ng-5.0.0/tests/test_pvpc_zones.py +43 -0
  40. aiopvpc_ng-5.0.0/tests/test_real_api_calls.py +67 -0
  41. aiopvpc_ng-5.0.0/tests/test_tariff_attributes.py +34 -0
  42. aiopvpc_ng-5.0.0/uv.lock +1085 -0
@@ -0,0 +1,59 @@
1
+ name: Build, test, publish
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ branches: [master]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Check out repository
18
+ uses: actions/checkout@v6
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v7
22
+
23
+ - name: Set up Python
24
+ run: uv python install
25
+
26
+ - name: Install the project
27
+ run: uv sync --locked --all-extras --dev
28
+
29
+ - name: Run tests
30
+ run: uv run pytest
31
+
32
+ - name: Build a binary wheel and a source tarball
33
+ run: uv build
34
+
35
+ - name: Store the distribution packages
36
+ uses: actions/upload-artifact@v5
37
+ with:
38
+ name: python-package-distributions
39
+ path: dist/
40
+
41
+ publish-to-pypi:
42
+ name: Publish package to PyPI
43
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
44
+ needs:
45
+ - build
46
+ runs-on: ubuntu-latest
47
+ environment:
48
+ name: pypi
49
+ url: https://pypi.org/p/aiopvpc-ng
50
+ permissions:
51
+ id-token: write
52
+ steps:
53
+ - name: Download all the dists
54
+ uses: actions/download-artifact@v6
55
+ with:
56
+ name: python-package-distributions
57
+ path: dist/
58
+ - name: Publish distribution to PyPI
59
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,33 @@
1
+ name: Tests on PRs
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ jobs:
7
+ test-flow:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ id-token: write
11
+ contents: read
12
+ pull-requests: write
13
+ steps:
14
+ - name: Check out repository
15
+ uses: actions/checkout@v6
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v7
19
+
20
+ - name: Set up Python
21
+ run: uv python install
22
+
23
+ - name: Install the project
24
+ run: uv sync --locked --all-extras --dev
25
+
26
+ - name: Run tests
27
+ run: uv run pytest --cov-report xml:coverage.xml
28
+
29
+ - name: Get Cover
30
+ uses: orgoro/coverage@v3.1
31
+ with:
32
+ coverageFile: coverage.xml
33
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,103 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ pip-wheel-metadata/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ .idea
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ .hypothesis/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+
59
+ # Flask stuff:
60
+ instance/
61
+ .webassets-cache
62
+
63
+ # Scrapy stuff:
64
+ .scrapy
65
+
66
+ # Sphinx documentation
67
+ docs/_build/
68
+
69
+ # PyBuilder
70
+ target/
71
+
72
+ # Jupyter Notebook
73
+ .ipynb_checkpoints
74
+
75
+ # pyenv
76
+ .python-version
77
+
78
+ # celery beat schedule file
79
+ celerybeat-schedule
80
+
81
+ # SageMath parsed files
82
+ *.sage.py
83
+
84
+ # dotenv
85
+ .env
86
+
87
+ # virtualenv
88
+ .venv
89
+ venv/
90
+ ENV/
91
+
92
+ # Spyder project settings
93
+ .spyderproject
94
+ .spyproject
95
+
96
+ # Rope project settings
97
+ .ropeproject
98
+
99
+ # mkdocs documentation
100
+ /site
101
+
102
+ # mypy
103
+ .mypy_cache/
@@ -0,0 +1,37 @@
1
+ minimum_pre_commit_version: "3.0.4"
2
+ repos:
3
+ - repo: https://github.com/astral-sh/ruff-pre-commit
4
+ rev: v0.3.2
5
+ hooks:
6
+ - id: ruff
7
+ args:
8
+ - --fix
9
+ - id: ruff-format
10
+ - repo: "https://github.com/pre-commit/pre-commit-hooks"
11
+ rev: "v4.5.0"
12
+ hooks:
13
+ - id: end-of-file-fixer
14
+ - id: trailing-whitespace
15
+ - id: check-json
16
+ - id: check-toml
17
+ - id: check-yaml
18
+ - repo: https://github.com/pre-commit/mirrors-prettier
19
+ rev: v4.0.0-alpha.8
20
+ hooks:
21
+ - id: prettier
22
+ - repo: "https://github.com/pre-commit/mirrors-mypy"
23
+ rev: "v1.9.0"
24
+ hooks:
25
+ - id: "mypy"
26
+ name: "Check type hints (mypy)"
27
+ verbose: true
28
+ ci:
29
+ autofix_commit_msg: |
30
+ [pre-commit.ci] auto fixes from pre-commit.com hooks
31
+
32
+ for more information, see https://pre-commit.ci
33
+ autofix_prs: true
34
+ autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
35
+ autoupdate_schedule: monthly
36
+ skip: []
37
+ submodules: false
@@ -0,0 +1,249 @@
1
+ # Changelog
2
+
3
+ ## [v4.3.1](https://github.com/azogue/aiopvpc/tree/v4.3.1) - 🐛 Fix unsorted prices in composed sensor 'INDEXED' (2024-03-25)
4
+
5
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.3.0...v4.3.1)
6
+
7
+ - 🐛 Fix unsorted prices in composed sensor 'INDEXED' (#72)
8
+ - 👷 ci: Split actions for tests on PRs and publish package on main
9
+ - 👷 Remove codecov integration and produce reports instead (#71)
10
+
11
+ ## [v4.3.0](https://github.com/azogue/aiopvpc/tree/v4.3.0) - ✨ Add new _composed_ sensor for Indexed tariff (2024-03-10)
12
+
13
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.2.2...v4.3.0)
14
+
15
+ - ✨ Add new price sensors: **Market adjustment** (from ESIOS API indicator 2108), and **Indexed tariff** (as _composed_ price sensor calculated as `PVPC - ADJUSTMENT`), from first-time contributor @MiguelAngelLV in #69 🍻, and some adjustments in #70
16
+ - 🎨 pre-commit updates and change to `ruff` + `ruff-format` instead of `black` and `isort`
17
+ - 🚀 Bump minor version and update deps and CHANGELOG.md
18
+
19
+ ## [v4.2.2](https://github.com/azogue/aiopvpc/tree/v4.2.2) - ♻️ Remove python upper limit (2023-07-30)
20
+
21
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.2.1...v4.2.2)
22
+
23
+ - ♻️ Remove python upper limit (from @cdce8p in #59)
24
+ - 🎨 pre-commit autoupdate
25
+ - 📦️ Bump minor version and update deps and CHANGELOG.md
26
+
27
+ ## [v4.2.1](https://github.com/azogue/aiopvpc/tree/v4.2.1) - Fix injection price sensor attributes (2) (2023-05-29)
28
+
29
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.2.0...v4.2.1)
30
+
31
+ - 🐛 Fix one-line conditional matching for 'not None' instead of positive value 🙈
32
+ - ✅ tests: Add unit test for price sensor attributes
33
+
34
+ ## [v4.2.0](https://github.com/azogue/aiopvpc/tree/v4.2.0) - Fix injection price sensor attributes (2023-05-29)
35
+
36
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.1.0...v4.2.0)
37
+
38
+ - 🐛 Fix attributes 'max_price_at' and 'min_price_at' for injection price sensor (were swapped)
39
+ - 📦️ Bump minor version and update deps
40
+ - 📝 Fix usage example in README.md
41
+ - 🎨 pre-commit autoupdate and swap `flake8` for `ruff`
42
+ - 📝 Fix links in CHANGELOG.md
43
+
44
+ ## [v4.1.0](https://github.com/azogue/aiopvpc/tree/v4.1.0) - Adapt to 403 unauthorized error (2023-03-12)
45
+
46
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.0.1...v4.1.0)
47
+
48
+ - 🐛 Process 403 error from server like '401 unauthorized', raising `BadApiTokenAuthError`
49
+ to signal HA for reauth-config for both status codes, when API token is enabled.
50
+
51
+ ## [v4.0.1](https://github.com/azogue/aiopvpc/tree/v4.0.1) - Minor fixes (2023-01-11)
52
+
53
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v4.0.0...v4.0.1)
54
+
55
+ - ✏️ Fix typo on 'injection' keyword (was badly typed as _spanglish_ 'inyection' 😅)
56
+ - 🐛 Fix unit for price sensors attributes (from €/MWh to €/kWh)
57
+
58
+ ## [v4.0.0](https://github.com/azogue/aiopvpc/tree/v4.0.0) - Implement ESIOS API Token (2023-01-09)
59
+
60
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v3.0.0...v4.0.0)
61
+
62
+ - ✨ Implement **support to access the extended ESIOS API** with a personal token
63
+ (you must request yours by mailing to [consultasios@ree.es](mailto:consultasios@ree.es?subject=Personal%20token%20request)),
64
+ with initial support for the existent PVPC price sensor (ESIOS indicator code: **1001**), and **3 new ones** 🤩:
65
+ - **Inyection price** sensor (ESIOS indicator code: **1739**),
66
+ name: "Precio de la energía excedentaria del autoconsumo para el mecanismo de compensación simplificada"
67
+ - **MAG price** sensor (ESIOS indicator code: **1900**),
68
+ name: "Desglose peaje por defecto 2.0TD excedente o déficit de la liquidación del mecanismo de ajuste de costes de producción"
69
+ - **OMIE price** sensor (ESIOS indicator code: **10211**),
70
+ name: "Precio medio horario final suma de componentes"
71
+
72
+ - 💥 Remove 'apidatos' support as alternative _data-source_, leaving only public and private paths for https://api.esios.ree.es
73
+
74
+ - ✨ Signal bad auth for esios token calls with a custom exception, to handle 'reauth' flow in Home-Assistant
75
+
76
+ - ✨ Add helper methods for HA integration to manage unique ids for each sensor, to update the enabled sensors to download, and to check the API token
77
+
78
+ - ♻️ Use dataclasses for `EsiosApiData` and `EsiosResponse` data containers, instead of typed dicts
79
+
80
+ - ✅ tests: Update fixtures for esios sensors and adapt tests to the new interface and the multiple-sensors behaviour
81
+
82
+ - 📦️ Bump mayor version to **v4** and lighten dev-env, removing pre-commit related modules and adding python-dotenv
83
+
84
+ - (from #46, with v3.1.0) Remove `holidays` dependency to evaluate special days under 'P3' period and fix tests
85
+
86
+ ## [v3.0.0](https://github.com/azogue/aiopvpc/tree/v3.0.0) - Change Data Source to apidatos.ree.es (2021-12-05)
87
+
88
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.3.0...v3.0.0)
89
+
90
+ 🔥 **BREAKING-CHANGE**: this release **removes support for the old PVPC tariffs**
91
+ (prices < 2021-06-01), and the extra methods to use this library as a _dataloader_
92
+ (`.download_prices_for_range(...)`), leaving only the **code to support the HA Core integration**.
93
+
94
+ Motivated by recent successful attempts to kick us out from `api.esios.ree.es`,
95
+ we are changing the data source to another REE public server, at `apidatos.ree.es`,
96
+ with the same information than the current one, available without authentication 👌
97
+
98
+ **This release implements the new data-source**, but also maintains the _legacy_ one.
99
+
100
+ - Initial configuration is set with a new `data_source` parameter, **with the new source as default**.
101
+ - If a 403 status-code is received, the **data source is switched** (new to legacy / legacy to new), no retry is done,
102
+ and the User-Agent loop trick is only used for the legacy data-source.
103
+
104
+ **Changes:**
105
+
106
+ - :fire: Remove support for old PVPC tariffs and range download methods,
107
+ and make `tariff` and `websession` required arguments
108
+
109
+ - :sparkles: Add alternative data-source from 'apidatos.ree.es'
110
+ - Implement data parsing from `apidatos.ree.es`, using endpoint at `/es/datos/mercados/precios-mercados-tiempo-real`
111
+ - Add `data_source` parameter with valid keys 'apidatos' and 'esios_public', setting the new one as default ;-)
112
+ - Remove retry call if 403 status is received, but maintain the User-Agent loop, and also toggle the data-source for the next call
113
+ - Move old ATTRIBUTION to `.attribution` property, as function of the data-source
114
+
115
+ - :truck: Change test patterns to new tariffs by substituting old examples in DST days from 2019 to equivalent days since 2021-06, using the new tariff keys
116
+
117
+ - :truck: Add test patterns from new data-source, and adjust tests
118
+
119
+ ## [v2.3.0](https://github.com/azogue/aiopvpc/tree/v2.3.0) - Decrease API refresh rate and try to avoid banning (2021-12-01)
120
+
121
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.4...v2.3.0)
122
+
123
+ Quick-Fix Release motivated by the last change in the ESIOS server (on 2021-11-30 😱),
124
+ which is now apparently banning HomeAssistant requests,
125
+ filtering us out because of the 'User-Agent' headers data 😤,
126
+ as the server is returning a 403 status code error for a PUBLIC url 🤷.
127
+
128
+ **Changes:**
129
+
130
+ - :zap: **Substantially decrease the number of API requests to ESIOS**,
131
+ avoiding unnecesary calls to refresh data for the same electricity prices.
132
+ Before, when used from the `pvpc_hourly_pricing` HA Core integration,
133
+ the ESIOS API was called 2 times/hour from 0h to 20h, and 4 times/hour in the evening,
134
+ from 20h to 0h, retrieving today + tomorrow prices.
135
+ This makes a total of ~56 requests/day, which is _not a lot_ 😅,
136
+ but it seems the aggregated total for the HA user base (🔥 >30k requests/day just
137
+ counting users pushing HA analytics) is being some kind of a problem for ESIOS,
138
+ as it looks like they're trying to bane us 🥺😭
139
+ Now, the API handler avoids calls to retrieve already available prices,
140
+ cutting down the number of requests to just 1-2 requests/day 🤩
141
+
142
+ - :bug: **Set standard `User-Agent` header info**, to try to avoid server-side banning 🙈,
143
+ and _rotate_ it if banning is detected, using common User-Agent browser identifiers.
144
+
145
+ - :recycle: Minor code refactor to prepare for future library changes, in order to move to authenticated API endpoints in future versions.
146
+
147
+ ## [v2.2.4](https://github.com/azogue/aiopvpc/tree/v2.2.4) - Split today / tomorrow price sensor attributes (2021-11-20)
148
+
149
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.2...v2.2.4)
150
+
151
+ **Changes:**
152
+
153
+ - Generate different sets of sensor attributes for hourly prices for current day and for the next day (available at evening), so attrs like `price_position` or `price_ratio` don't change for the current day when next-day prices are received.
154
+
155
+ ## [v2.2.2](https://github.com/azogue/aiopvpc/tree/v2.2.2) - Migrate CI from travis to gh-actions (2021-11-04)
156
+
157
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.1...v2.2.2)
158
+
159
+ **Changes:**
160
+
161
+ - :art: Add isort to pre-commit config
162
+ - :green_heart: Add configuration for pre-commit.ci to run linter checks there
163
+ - :green_heart: CI flow with GitHub Actions to
164
+ - install library with `poetry`
165
+ - run tests
166
+ - upload coverage when merging to master
167
+ - publish a new pypi version when merging to master if `pyproject.toml` changes
168
+ - :fire: Remove previus travis CI config
169
+
170
+ ## [v2.2.1](https://github.com/azogue/aiopvpc/tree/v2.2.1) - Quickfix for 403 status code from ESIOS API (2021-11-03)
171
+
172
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.0...v2.2.1)
173
+
174
+ **Changes:**
175
+
176
+ - Fix Esios request returning a 403 status code since 2021-11-02, by:
177
+ - just adding an 'User-Agent' to request headers, if `aiohttp==3.7.4.post0`
178
+ - or upgrading to `aiohttp==3.8.0`, where it is not needed and the original request works like before
179
+ - Add better error logging for this 'forbidden' error if reappears in the future
180
+ - Update deps, requiring holidays>0.11.1
181
+
182
+ ## [v2.2.0](https://github.com/azogue/aiopvpc/tree/v2.2.0) - New sensor attributes for new tariff 2.0TD (2021-06-12)
183
+
184
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.1.2...v2.2.0)
185
+
186
+ **Changes:**
187
+
188
+ - Determine tariff period (P1/P2/P3) for current hour, and calculate the delta hours to the next one, publishing attributes `period`, `next_period`, and `hours_to_next_period`
189
+ - Add `price_ratio`, `max_price`, and `max_price_at` attributes
190
+ - When there are cheaper prices ahead, add attributes `next_better_price`, `hours_to_better_price`, and `num_better_prices_ahead`
191
+ - Add `price_position` attribute (1 for cheaper price, 24 for the most high-priced), as suggested by @r-jordan in #23
192
+ - Add contracted power in kW as new parameters (power for P1/P2 and power for P3) to show the `available_power` for each period
193
+ - Use `holidays` library to retrieve national holidays where to apply the valley period P3 for the full day
194
+
195
+ ## [v2.1.2](https://github.com/azogue/aiopvpc/tree/v2.1.2) - Quick adapt to new tariff 2.0TD (2021-05-31)
196
+
197
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.1.1...v2.1.2)
198
+
199
+ **Changes:**
200
+
201
+ - Use "PCB" and "CYM" keys to retrieve prices for dates > 2021-06-01 to match new JSON from Esios API for new '2.0 TD' tariff.
202
+ - Add new flag to set prices for Ceuta & Melilla (to use "CYM" identifier instead of "PCB")
203
+
204
+ ## [v2.1.1](https://github.com/azogue/aiopvpc/tree/v2.1.1) - Fix prices badly assigned outside default timezone (2021-05-16)
205
+
206
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.0.2...v2.1.1)
207
+
208
+ **Changes:**
209
+
210
+ - Remove `pytz` dependency and handle timezones with `zoneinfo` (related to [this article](https://developers.home-assistant.io/blog/2021/05/07/switch-pytz-to-python-dateutil)),
211
+ and adapt to use input timezone as a time zone object or a string identifier.
212
+ - **Fix prices being badly assigned in Canary Islands timezone**.
213
+ Before, prices where **assumed absolute in time**, and marked with tz-aware UTC datetimes,
214
+ but that behavior was incorrect 😔, as prices are applicable _by-hour_, independently of the timezone.
215
+ So now the produced prices are **shifted**, to apply the correct ones for each local hour, so given the price at 10AM,
216
+ it will be the same across all timezones. THIS IS A **BREAKING CHANGE** over the old behavior, if you live in the Canary Islands (because before the prices were incorrect!)
217
+ - Fix sensor attributes in month changes (there were badly tagged as "price last day" instead of "price next day" 🤪).
218
+ - Update tests suite to use `pytest-asyncio` instead of `pytest-aiohttp`, add `mypy` to pre-commit, and a general dependency update.
219
+
220
+ ## [v2.0.2](https://github.com/azogue/aiopvpc/tree/v2.0.2) - Unpinned requirements (2020-08-04)
221
+
222
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.0.1...v2.0.2)
223
+
224
+ **Changes:**
225
+
226
+ - Fix outdated pinned requirements by setting just a minimal version, and syncing those with HomeAssistant
227
+
228
+ ## [v2.0.1](https://github.com/azogue/aiopvpc/tree/v2.0.1) - Add methods to download a range of days (2020-05-07)
229
+
230
+ [Full Changelog](https://github.com/azogue/aiopvpc/compare/v1.0.2...v2.0.1)
231
+
232
+ **Implemented enhancements:**
233
+
234
+ - Async & blocking methods to download prices for a range of days.
235
+ - Use an `asyncio.Queue` to control concurrency for downloading a bunch of days, by creating a `concurrency_calls` number of workers.
236
+ - Make specific tariff optional, to get ALL PVPC detailed data when None, with schema `Dict[datetime, Dict[str, float]` instead of tariff-specific `Dict[datetime, float]`.
237
+
238
+ **Changes:**
239
+
240
+ - Make rest of init parameters also optional, to easier instantiation with `PVPCData()`.
241
+ - Add minimal doc in README and an example of use for bulk download of PVPC prices
242
+
243
+ ## [v1.0.2](https://github.com/azogue/aiopvpc/tree/v1.0.2) - Fix timezone support outside Europe/Madrid zone.
244
+
245
+ ## [1.0.0] - Initial
246
+
247
+ **Implemented**
248
+
249
+ - Basic data handler `PVPCData` to `.async_update_prices` and `process_state_and_attributes` for the PVPC HA sensor.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Eugenio Panadero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiopvpc-ng
3
+ Version: 5.0.0
4
+ Summary: async downloader for Spanish Electricity hourly prices (PVPC). Fork from aiopvpc due to inactivity of the original project
5
+ Project-URL: Repository, https://github.com/zeehio/aiopvpc-ng
6
+ Author-email: Eugenio Panadero <eugenio.panadero@gmail.com>
7
+ Maintainer-email: Sergio Oller <sergioller@gmail.com>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: aiohttp>=3.7.4.post0
12
+ Requires-Dist: async-timeout>=3.0.1
13
+ Requires-Dist: tzdata>=2025.3
14
+ Description-Content-Type: text/markdown
15
+
16
+ [![PyPI Version][pypi-image]][pypi-url]
17
+ [![pre-commit.ci Status][pre-commit-ci-image]][pre-commit-ci-url]
18
+ [![Build Status][build-image]][build-url]
19
+
20
+ <!-- Badges -->
21
+
22
+ [pypi-image]: https://img.shields.io/pypi/v/aiopvpc-ng
23
+ [pypi-url]: https://pypi.org/project/aiopvpc-ng/
24
+ [pre-commit-ci-image]: https://results.pre-commit.ci/badge/github/zeehio/aiopvpc-ng/master.svg
25
+ [pre-commit-ci-url]: https://results.pre-commit.ci/latest/github/zeehio/aiopvpc-ng/master
26
+ [build-image]: https://github.com/zeehio/aiopvpc-ng/actions/workflows/main.yml/badge.svg
27
+ [build-url]: https://github.com/zeehio/aiopvpc-ng/actions/workflows/main.yml
28
+
29
+ # aiopvpc-ng
30
+
31
+ Fork of [azogue/aiopvpc](https://github.com/azogue/aiopvpc) due to upstream inactivity.
32
+
33
+ Simple aio library to download Spanish electricity hourly prices.
34
+
35
+ Made to support the [**`pvpc_hourly_pricing`** HomeAssistant integration](https://www.home-assistant.io/integrations/pvpc_hourly_pricing/).
36
+
37
+ ## Install
38
+
39
+ Install with `pip install aiopvpc-ng` or clone it to run tests or anything else.
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ import aiohttp
45
+ from datetime import datetime, timezone
46
+ from aiopvpc_ng import PVPCData
47
+
48
+ async with aiohttp.ClientSession() as session:
49
+ pvpc_handler = PVPCData(session=session, tariff="2.0TD")
50
+ esios_data = await pvpc_handler.async_update_all(
51
+ current_data=None, now=datetime.now(timezone.utc)
52
+ )
53
+ print(esios_data.sensors["PVPC"])
54
+ ```
@@ -0,0 +1,39 @@
1
+ [![PyPI Version][pypi-image]][pypi-url]
2
+ [![pre-commit.ci Status][pre-commit-ci-image]][pre-commit-ci-url]
3
+ [![Build Status][build-image]][build-url]
4
+
5
+ <!-- Badges -->
6
+
7
+ [pypi-image]: https://img.shields.io/pypi/v/aiopvpc-ng
8
+ [pypi-url]: https://pypi.org/project/aiopvpc-ng/
9
+ [pre-commit-ci-image]: https://results.pre-commit.ci/badge/github/zeehio/aiopvpc-ng/master.svg
10
+ [pre-commit-ci-url]: https://results.pre-commit.ci/latest/github/zeehio/aiopvpc-ng/master
11
+ [build-image]: https://github.com/zeehio/aiopvpc-ng/actions/workflows/main.yml/badge.svg
12
+ [build-url]: https://github.com/zeehio/aiopvpc-ng/actions/workflows/main.yml
13
+
14
+ # aiopvpc-ng
15
+
16
+ Fork of [azogue/aiopvpc](https://github.com/azogue/aiopvpc) due to upstream inactivity.
17
+
18
+ Simple aio library to download Spanish electricity hourly prices.
19
+
20
+ Made to support the [**`pvpc_hourly_pricing`** HomeAssistant integration](https://www.home-assistant.io/integrations/pvpc_hourly_pricing/).
21
+
22
+ ## Install
23
+
24
+ Install with `pip install aiopvpc-ng` or clone it to run tests or anything else.
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ import aiohttp
30
+ from datetime import datetime, timezone
31
+ from aiopvpc_ng import PVPCData
32
+
33
+ async with aiohttp.ClientSession() as session:
34
+ pvpc_handler = PVPCData(session=session, tariff="2.0TD")
35
+ esios_data = await pvpc_handler.async_update_all(
36
+ current_data=None, now=datetime.now(timezone.utc)
37
+ )
38
+ print(esios_data.sensors["PVPC"])
39
+ ```
@@ -0,0 +1,14 @@
1
+ """Simple aio library to download Spanish electricity hourly prices."""
2
+
3
+ from .const import DEFAULT_POWER_KW, EsiosApiData, TARIFFS
4
+ from .ha_helpers import get_enabled_sensor_keys
5
+ from .pvpc_data import BadApiTokenAuthError, PVPCData
6
+
7
+ __all__ = (
8
+ "BadApiTokenAuthError",
9
+ "EsiosApiData",
10
+ "DEFAULT_POWER_KW",
11
+ "PVPCData",
12
+ "TARIFFS",
13
+ "get_enabled_sensor_keys",
14
+ )