-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ESIOS API Token support #47
Conversation
and assert a valid tariff in init
* Add optional `esios_api_token` to `PVPCData`, to pair with `data_source="esios"` * Handle and log error for bad token auth response (401 status) for "esios" source * Add parsing logic and URL mask for ESIOS indicators data for PVPC (ind=1001) * Add geozones array to const.py
and instead return an `EsiosApiData` dict when calling `async_update_all`, as first step to avoid 'state' storage in the API handler, to completely relay on the DataUpdateCoordinator schema of HA. Sensor states and attributes are still stored on `.states` and `.sensor_attributes`, but that should change in the future. When using the private API with the ESIOS token, both authentication headers are set (the old with 'Authorization' and the upcoming one with 'x-api-key') All esios sensors have the same 'price attributes' of the PVPC sensor, excluding the tariff/period related attrs
to access `ESIOS_TOKEN` env var and make private calls
and lighten dev-env, removing pre-commit related modules and adding python-dotenv
to manage unique ids for each sensor, and to update the enabled sensors to download
Sorry @azogue if I'm posting this in the wrong place. How do I add this new version to HA? Is it already available as an integration? or should I download it from somewhere else and place it in the custom_components folder? |
I have to make a PR in ha-core, and another one in the ha-docs. Then goes the review process, and after the merge, these kind of changes are published in the monthly releases. I'll try to make it for v2023.2.0 🤞, but I'm not sure it will be on time 😰 In the meanwhile, for beta-testing it, you may copy and decompress this pvpc_hourly_pricing.zip into your (zip updated at 2023-01-11 09:55h) |
Thank you for the new version @azogue. I have installed it successfully (I will report any other issues). I see that the hourly prizes (current and next day) included in the sensors as attributes are now rendered in €/Mwh whereas the sensor value and some other attributes are in €/Kwh. |
Hi @enredador, that was an error 🙈 When developing it, I saw that the new HA frontend renders numeric attributes for entities with 2 decimals max, so for most sensors with values < 100 €/MWh, the price attributes appeared as As I was not sure if it was my fault, I changed them to €/MWh, and then I forgot about them 😱 I'll revert it with a new version patch with the fix 🚀 |
The zip package is updated to point to |
Thank you @azogue. I made the changes and it is running ok now. May be using €-cents/kWh as unit would have been a more readable choice. |
This V4.0.1 works fine with the API token. I still can't see surplus (injection) prices, am I doing something wrong? |
Hi! I just published, as a new repository, the 'custom' version of the official component, to replace directly the one included in HA, with the pending changes since January 🐢 It is here: https://github.com/azogue/ha-pvpc-custom And it is compatible with HACS, adding that link as 'custom repository' with 'category' "Integration" 👍 I recommend everyone to install this new custom component and remove all those components downloaded in some zip (including that 'esios'). |
✨ Implement support to access the extended ESIOS API with a personal token
(you must request yours by mailing to [email protected]), with initial support for the existent PVPC price sensor (ESIOS indicator code: 1001), and 3 new ones 🤩:
💥 Remove 'apidatos' support as alternative data-source, leaving only public and private paths for https://api.esios.ree.es
✨ Signal bad auth for esios token calls with a custom exception, to handle 'reauth' flow in Home-Assistant
✨ 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
♻️ Use dataclasses for
EsiosApiData
andEsiosResponse
data containers, instead of typed dicts✅ tests: Update fixtures for esios sensors and adapt tests to the new interface and the multiple-sensors behaviour
📦️ Bump mayor version to v4 and lighten dev-env, removing pre-commit related modules and adding python-dotenv
closes #9 #45