dchaves
(David Chaves)
March 1, 2022, 4:31pm
1
In addition to the energy cost, it would be very useful to have a sensor with the self-consumption surplus energy price for solar installations in Spain.
There is a modified component with support PVPC injection price:
azogue:master
β azogue:fix/user-agent-banning
opened 08:08PM - 01 Dec 21 UTC
closes #34
related to https://github.com/home-assistant/core/issues/60556
β¦
Quick-Fix motivated by the last change in the ESIOS server (on 2021-11-30 π±), which is now apparently banning HomeAssistant requests, filtering us out because of the 'User-Agent' headers data π€, as the server is returning a 403 status code error for a PUBLIC url π€·.
So, [until future moves to authenticated endpoints](https://github.com/azogue/aiopvpc/issues/9#issuecomment-968049577), or alternative data sources, _let's continue playing π and π with the ESIOS webadmins_ π€£π€£
[Serious note for those webadmins]: I'm just a volunteer, and I'm an email away for contact, so please, if you are reading this, give me a call before filtering us all out π€π₯Ί
### **Changes:**
* :zap: **Substantially decrease the number of API requests to ESIOS**, avoiding unnecessary calls to refresh data for the same electricity prices.
Before, when used from the `pvpc_hourly_pricing` HA Core integration, the ESIOS API was called 2 times/hour from 0h to 20h, and 4 times/hour in the evening, from 20h to 0h, retrieving today + tomorrow prices.
This makes a total of ~56 requests/day, which is _not a lot_ π
, but it seems the aggregated total for the HA user base (π₯ >30k requests/day just counting users pushing HA analytics) is being some kind of a problem for ESIOS,
as it looks like they're trying to bane us π₯Ίπ
Now, the API handler avoids calls to retrieve already available prices, cutting down the number of requests to **just 1-2 requests/day** π€©
* :bug: **Set standard `User-Agent` header info**, to try to avoid server-side banning π, and _rotate_ it if banning is detected, using common User-Agent browser identifiers.
* :recycle: Minor code refactor to prepare for future library changes, in order to move to authenticated API endpoints in future versions.
But yes, I think we need this in oficial version of PVPC component
1 Like