-
Notifications
You must be signed in to change notification settings - Fork 112
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
first pass #127
base: master
Are you sure you want to change the base?
first pass #127
Conversation
With the version from yesterday there is a bug that it keeps the same prices for tommorow. Raw today and Raw tomorrow have both same data, same timestamps, same values. |
2022-04-02 10:37:35 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform nordpool is taking over 10 seconds. Starts already for 4 minutes. something is wrong there... |
Please enable the debug log and the log. The sensor can take a long time depending on the issues it has |
The integration made 69 requests to finally get data. i think it fails if prices are requested before midday (when new prices are published) |
@yozik04 Thanks for the debug log! It was really helpful, the problem was that the retry method considers all "falsy" as a request for retrying. Ill fix that :) |
The method you used to make nordpool library async is very scary. I'd better throw a PR to add async to that library. =) |
BTW. Take a look to the latest version of that library. It already has async support. |
Ahh, you have just made a copy of that async version and modified... Ok, your code, your rules... |
@yozik04 The API wasn't async when I made this, I was the one that sent an upstream PR to make it async. I kept my code to make sure that it worked. See PR kipe/nordpool#8 and kipe/nordpool#11 If you have a better way to make this async while supporting multiple async HTTP libraries, feel free to send a PR |
@yozik04 I think it's ready to be merged. Can you test and leave it running until the prices for Monday should be available? |
@Hellowlol I will. Updating |
It still does 6 requests to nordpool on HA restart. |
Updating todays prices and Updating tomorrows prices. 3 requests each. |
@yozik04 thats intended. The api stores/get the data in cet. So if you requested data area in another time zone you wouldn’t get the correct prices. That’s why we request data for 3 days and extract what we need. |
It is ok to fetch 3. But why it fetches 3 requests two times. |
Its one request for today and one for tomorrow. |
Looks like in my region prices appear at 15:00 UTC+3. For some reason it started requesting at 14:00, which is 11 UTC.
|
Ahh, my father has restarted HA in the morning. He told it showed today and tomorrow same prices... |
@yozik04 can you post the log? I want to check why it started requesting data then |
Thanks for your suggestion, that is pretty much how this is designed today with some small changes to be able to handle currencies and we also need to clear the sensors data in addition to
I'll accept every PR that makes the sensor more reliable as long as none of the current features are missed. 😊 |
Ill add some tests |
At night both day prices became unavailable with new version. Will send logs later. |
Todays log: nordpool-2022-04-04.log |
yesterday's logs were lost unfortunately. |
Thanks, that was helpful. 👍 The server was restarted after midnight so there isn't any available data for tomorrow, it will try one then, stop. However, it also did a new HTTP call to get today's data. There were invalid values in FI results, so the requests for retried over and over until the setup of the senor failed. We validate on currency as the NordpoolData don't know what data the user wants |
nordpool_2022-04-04_05.log |
I can confirm the last one is working as expected. |
@yozik04 Can you do one last test? I was thinking of making a new release this weekend. |
Pulled latest changes. |
if the user has multiple regions all of them have to be valid
The latest update should only verify the area that the user requested. If the user has multiple sensors using the same currency, then all of the data for the selected areas have to be valid. |
Logs from version 34be90f JSON files that were fetched at night: # 2022-04-07 00:33:08 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=06-04-2022 {'currency': 'EUR', 'endDate': '06-04-2022'}
cat 06-04-2022.txt | jq -c '[.data.Rows[].Columns | map(select(.Name == "EE"))[].Value]'
["81,73","72,17","69,23","71,48","74,79","74,13","87,07","136,61","151,41","95,96","90,42","87,16","86,68","84,67","84,90","86,91","87,68","87,63","87,91","104,52","111,75","54,68","45,08","27,35","27,35","151,41","85,08","94,65","83,40","59,72"]
# 2022-04-07 00:33:08 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=07-04-2022 {'currency': 'EUR', 'endDate': '07-04-2022'}
cat 07-04-2022.txt | jq -c '[.data.Rows[].Columns | map(select(.Name == "EE"))[].Value]'
["81,73","72,17","69,23","71,48","74,79","74,13","87,07","136,61","151,41","95,96","90,42","87,16","86,68","84,67","84,90","86,91","87,68","87,63","87,91","104,52","111,75","54,68","45,08","27,35","27,35","151,41","85,08","94,65","83,40","59,72"]
# 2022-04-07 00:33:08 DEBUG (MainThread) [custom_components.nordpool.aio_price] requested https://www.nordpoolgroup.com/api/marketdata/page/10?currency=EUR&endDate=08-04-2022 {'currency': 'EUR', 'endDate': '08-04-2022'}
cat 08-04-2022.txt | jq -c '[.data.Rows[].Columns | map(select(.Name == "EE"))[].Value]'
["-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-"] As you can see 6th April's data is absolutely equal to 7th April, what is bullshit. 8th is not available. |
Thanks again! Clearly it’s bug in the retry. However I have no idea why the values for today and tomorrow was the same. How if you get the json? Did you do manual request and download it? The raw json isn’t logged in this integration. |
I have copied urls from the HA log and used wget at that time. |
Hi! Just a friendly poke to see how this is progressing? I've seen this issue a couple of times so that's the reason. Great work btw. |
I haven't forgotten this. I just got frustrated with the API returning junk :P It will get merged sometime in the future :D |
This PR is an attempt to make the integration more resilient against Nordpool API errors, by retrying on HTTP errors and missing/wrong data with exponential retries.