openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[linky] Requests returning internal server error #13377

Closed lolodomo closed 2 years ago

lolodomo commented 2 years ago

Binding connection is working. Request to retrieve day consumptions is sometimes working. Requests to retrieve month consumptions, year consumptions and power states are failing with an internal server error. At binding startup, there are 4 data requests, at first try, only the second succeeded. At the second and third tries, all failed

12:50:38.465 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "power cache" is requiring a fresh value
12:50:38.471 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getPowerData from 2022-09-10 to 2022-09-11
12:50:39.169 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting power data: Error requesting 'https://apps.lincs.enedis.fr/mes-mesures/api/private/v1/personnes/xxxxx/prms/yyyyy/donnees-pmax?dateDebut=10-09-2022&dateFin=11-09-2022&mesuretypecode=CONS' : {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}

12:50:40.001 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "monthly cache" is requiring a fresh value
12:50:40.006 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getConsumptionData from 2022-08-01 to 2022-09-11
12:50:40.474 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting consumption data: Error requesting 'https://apps.lincs.enedis.fr/mes-mesures/api/private/v1/personnes/xxxxx/prms/yyyyy/donnees-energie?dateDebut=01-08-2022&dateFin=11-09-2022&mesuretypecode=CONS' : {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}

12:50:40.520 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "yearly cache" is requiring a fresh value
12:50:40.527 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getConsumptionData from 2021-01-01 to 2022-09-11
12:50:41.023 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting consumption data: Error requesting 'https://apps.lincs.enedis.fr/mes-mesures/api/private/v1/personnes/xxxx/prms/yyyyy/donnees-energie?dateDebut=01-01-2021&dateFin=11-09-2022&mesuretypecode=CONS' : {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}

@clinique for information.

lolodomo commented 2 years ago

It might have been a temporary issue on enedis servers, it looks like it is now working. I will continue to monitor during the next days and I will reopen the issue if I notice problems.

lolodomo commented 2 years ago

I observed my logs on the last days. Every morning at 1 am and sometimes even at 3 am, the request to get the power peak of the current day leads to an internal server error and as a consequence the thing going OFFLINE. Note that it goes ONLINE immediately after because the requests to get consumptions are succeeding.

I suppose the server returns an internal error because the data is not yet available. Maybe if we requested the data for yesterday and the previous day, the server will return something. I am going to test that.

lolodomo commented 2 years ago

I suppose the server returns an internal error because the data is not yet available. Maybe if we requested the data for yesterday and the previous day, the server will return something. I am going to test that.

This was apparently a good idea, I got no internal server error this morning. I will submit a PR.