Skip to content
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

[linky] Yet another website underlaying API modification #17538

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

clinique
Copy link
Contributor

@clinique clinique commented Oct 10, 2024

Resolves #17513

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
@clinique clinique self-assigned this Oct 10, 2024
@clinique clinique added the bug An unexpected problem or unintended behavior of an add-on label Oct 10, 2024
@clinique
Copy link
Contributor Author

This gives a first answer to the initial connection issue but I must investigate a bit, data may have changed leading to UNDEF items.

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
@lolodomo
Copy link
Contributor

I will test this evening and finish the review.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 11, 2024

@clinique : is your upgrade of jsoup really necessary ? I can't start the binding with your new version.

If I update my bundle with command bundle:update:

22:59:24.572 [ERROR] [Events.Framework                     ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.linky [278]
  Unresolved requirement: Import-Package: org.jsoup; version="[1.15.0,2.0.0)"

        at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.container.ModuleContainer.update(ModuleContainer.java:419) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.storage.Storage.update(Storage.java:969) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.storage.Storage.update(Storage.java:935) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.update(EquinoxBundle.java:490) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.apache.karaf.bundle.command.Update.update(Update.java:74) ~[?:?]
        at org.apache.karaf.bundle.command.Update.doExecute(Update.java:51) ~[?:?]
        at org.apache.karaf.bundle.command.BundleCommand.execute(BundleCommand.java:49) ~[?:?]
        at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:88) ~[?:?]
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68) ~[?:?]
        at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86) ~[?:?]
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) ~[?:?]
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) ~[?:?]
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) ~[?:?]
        at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) ~[?:?]
        at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
        at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
        at java.lang.Thread.run(Unknown Source) ~[?:?]

If I uninstall the bundle and then put the jar file in folder addons:


23:02:16.166 [WARN ] [org.apache.felix.fileinstall         ] - Error while starting bundle: file:/xxxxxxx/openhab/addons/linky.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.linky [299]
  Unresolved requirement: Import-Package: org.jsoup; version="[1.15.0,2.0.0)"

        at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.7.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.7.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.7.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.7.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.7.4]

@lolodomo
Copy link
Contributor

lolodomo commented Oct 11, 2024

Please upgrade jsoup in a separate PR.

I am now trying to remove jsoup upgrade to be able to test the fix!

@lolodomo
Copy link
Contributor

Please upgrade jsoup in a separate PR.

This will also facilitate backport to branch 4.2.x.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 11, 2024

If I remove jsoup upgrade, I am able to use the binding again and it is alive (ONLINE) again, bravo.
You made a mistake with channels for years but except this mistake the channels are apparently set again with values.
I will check tomorrow if the values are consistent with what I get from the web site.

@clinique
Copy link
Contributor Author

If I remove jsoup upgrade, I am able to use the binding again and it is alive (ONLINE) again, bravo. You made a mistake with channels for years but except this mistake the channels are apparently set again with values. I will check tomorrow if the values are consistent with what I get from the web site.

When I switch my dev environment to linky I always have a hard time (mvn clean install, update project, clean project...) resolving dependencies (especially jsoup). I had a look at what was used by other binding and saw 1.14.3, 1.15.3 and 1.15.4. On maven rep I saw that 1.14.3 had 3 security issues. Reason why I made this move but I can revert to 1.14.3

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
@lolodomo
Copy link
Contributor

When I switch my dev environment to linky I always have a hard time (mvn clean install, update project, clean project...) resolving dependencies (especially jsoup). I had a look at what was used by other binding and saw 1.14.3, 1.15.3 and 1.15.4. On maven rep I saw that 1.14.3 had 3 security issues. Reason why I made this move but I can revert to 1.14.3

Changing this dependency seems to prevent the update of the binding in an existing OH setup.
But I guess that it might work if I build and install a full new distribution.
So it is better to have this PR without jsoup upgrade, we could even distribute the jar file and it could be installed by users in their current OH version.
But you can create a separate PR for jsoup upgrade and this change will be integrated in our next OH versions.

@lolodomo
Copy link
Contributor

lolodomo commented Oct 12, 2024

I just installed the very last version and the internal server error is back ! Let's wait the retries during the day, it occurs that the service is not available before the end of the morning. I will see with the retry ar 11 am.

Edit: Still in error at 11 am.

Comment on lines -224 to +243
int idxLast = days.periodes.get(days.periodes.size() - 1).dateDebut.get(weekFields.dayOfWeek()) == 7 ? 2
: 1;
Aggregate weeks = values.aggregats.weeks;
if (weeks.datas.size() > idxLast) {
updateKwhChannel(LAST_WEEK, weeks.datas.get(idxLast));
}
if (weeks.datas.size() > (idxLast + 1)) {
updateKwhChannel(THIS_WEEK, weeks.datas.get(idxLast + 1));
} else {
updateKwhChannel(THIS_WEEK, 0.0);
}
setCurrentAndPrevious(values.aggregats.weeks, THIS_WEEK, LAST_WEEK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be sure that the proper week values are delivered every day of the week. I previously implemented it to have a proper 0 value each Monday as current week value and not the value from last week.
So before merging, I will check if the week values are correct Saturday (today), Sunday, Monday and Tuesday.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I'm not in a hurry.

@clinique
Copy link
Contributor Author

When I switch my dev environment to linky I always have a hard time (mvn clean install, update project, clean project...) resolving dependencies (especially jsoup). I had a look at what was used by other binding and saw 1.14.3, 1.15.3 and 1.15.4. On maven rep I saw that 1.14.3 had 3 security issues. Reason why I made this move but I can revert to 1.14.3

Changing this dependency seems to prevent the update of the binding in an existing OH setup. But I guess that it might work if I build and install a full new distribution. So it is better to have this PR without jsoup upgrade, we could even distribute the jar file and it could be installed by users in their current OH version. But you can create a separate PR for jsoup upgrade and this change will be integrated in our next OH versions.

I'll make a separate PR then. This will reduce a bit the number of bindings being on 1.14.x (we are far behind main branch of jsoup 1.18.1) and there are known vulnerabilities up to 1.15.2

@lolodomo
Copy link
Contributor

lolodomo commented Oct 12, 2024

I just installed the very last version and the internal server error is back ! Let's wait the retries during the day, it occurs that the service is not available before the end of the morning. I will see with the retry ar 11 am.

Edit: Still in error at 11 am.

Still not working for me at Midday.. Can you try on your side ?

@clinique
Copy link
Contributor Author

clinique commented Oct 12, 2024

I just installed the very last version and the internal server error is back ! Let's wait the retries during the day, it occurs that the service is not available before the end of the morning. I will see with the retry ar 11 am.
Edit: Still in error at 11 am.

Still not working for me at Midday.. Can you try on your side ?

Tested on my side, the same today.
Errors:
Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/HLC699EAZ/prms/21105933323207/donnees-pmax?dateDebut=10-10-2024&dateFin=12-10-2024&mesuretypecode=CONS'

Weird thing is the same query in the browser works without issue.

@clinique
Copy link
Contributor Author

clinique commented Oct 12, 2024

I just installed the very last version and the internal server error is back ! Let's wait the retries during the day, it occurs that the service is not available before the end of the morning. I will see with the retry ar 11 am.
Edit: Still in error at 11 am.

Still not working for me at Midday.. Can you try on your side ?

Now it works...
BtW I think I spotted an error : "Pic de Consommation" should be kVA, not W. I'll add a unitHint

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
@lolodomo
Copy link
Contributor

Now it works...

Still KO for me.

Comment on lines +17 to +19
<properties>
<bnd.importpackage>javax.annotation.meta;resolution:=optional</bnd.importpackage>
</properties>
Copy link
Contributor

@lolodomo lolodomo Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add that? What's the purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the way I found to solve the dependency resolution issue I faced.

Copy link
Contributor

@lolodomo lolodomo Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was building fine without that.

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
@lolodomo
Copy link
Contributor

Still KO today.

@clinique
Copy link
Contributor Author

Still KO today.

You may try to tace it in debug mode to understand where it's blocked.

@lolodomo
Copy link
Contributor

Here are my logs:

20:31:29.713 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from UNINITIALIZED (NOT_YET_READY) to INITIALIZING
20:31:29.721 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Initializing Linky handler.
20:31:29.729 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from INITIALIZING to UNKNOWN
20:31:29.739 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Starting login process for user: xxxxxxx@domain.fr
20:31:29.740 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 1: getting authentification
20:31:30.272 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Reception request SAML
20:31:30.276 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 2: send SSO SAMLRequest
20:31:30.425 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Get the location and the ReqID
20:31:30.435 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 3: auth1 - retrieve the template, thanks to cookie internalAuthId user is already set
20:31:30.894 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 4: auth2 - send the auth data
20:31:31.140 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Add the tokenId cookie
20:31:31.141 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 5: retrieve the SAMLresponse
20:31:31.240 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Step 6: post the SAMLresponse to finish the authentication
20:31:31.299 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from UNKNOWN to ONLINE
20:31:31.299 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "daily cache" is requiring a fresh value
20:31:31.300 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getConsumptionData from 2024-09-28 to 2024-10-13
20:31:31.394 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting consumption data: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=28-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
org.openhab.binding.linky.internal.LinkyException: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=28-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getContent(EnedisHttpApi.java:214) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getData(EnedisHttpApi.java:228) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getMeasures(EnedisHttpApi.java:263) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getEnergyData(EnedisHttpApi.java:268) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.getConsumptionData(LinkyHandler.java:363) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$0(LinkyHandler.java:101) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.refreshValue(ExpiringDayCache.java:86) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.getValue(ExpiringDayCache.java:73) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateDailyWeeklyData(LinkyHandler.java:241) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateData(LinkyHandler.java:202) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$4(LinkyHandler.java:175) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
        at java.lang.Thread.run(Unknown Source) [?:?]
20:31:31.401 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - calcNextExpiresAt result = 2024-10-14T01:00:00
20:31:31.402 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=28-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
20:31:31.407 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Update channel daily#yesterday with NaN
20:31:31.410 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Update channel weekly#thisWeek with NaN
20:31:31.411 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "monthly cache" is requiring a fresh value
20:31:31.412 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getConsumptionData from 2024-09-01 to 2024-10-13
20:31:31.557 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting consumption data: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
org.openhab.binding.linky.internal.LinkyException: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getContent(EnedisHttpApi.java:214) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getData(EnedisHttpApi.java:228) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getMeasures(EnedisHttpApi.java:263) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getEnergyData(EnedisHttpApi.java:268) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.getConsumptionData(LinkyHandler.java:363) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$2(LinkyHandler.java:129) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.refreshValue(ExpiringDayCache.java:86) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.getValue(ExpiringDayCache.java:73) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateMonthlyData(LinkyHandler.java:262) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateData(LinkyHandler.java:203) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$4(LinkyHandler.java:175) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
        at java.lang.Thread.run(Unknown Source) [?:?]
20:31:31.563 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - calcNextExpiresAt result = 2024-10-14T01:00:00
20:31:31.564 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from OFFLINE (COMMUNICATION_ERROR): Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=28-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"} to OFFLINE (COMMUNICATION_ERROR): Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
20:31:31.567 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Update channel monthly#thisMonth with NaN
20:31:31.569 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - getValue from cache "yearly cache" is requiring a fresh value
20:31:31.570 [DEBUG] [g.linky.internal.handler.LinkyHandler] - getConsumptionData from 2023-01-01 to 2024-10-13
20:31:31.719 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Exception when getting consumption data: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-01-2023&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
org.openhab.binding.linky.internal.LinkyException: Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-01-2023&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getContent(EnedisHttpApi.java:214) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getData(EnedisHttpApi.java:228) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getMeasures(EnedisHttpApi.java:263) ~[?:?]
        at org.openhab.binding.linky.internal.api.EnedisHttpApi.getEnergyData(EnedisHttpApi.java:268) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.getConsumptionData(LinkyHandler.java:363) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$3(LinkyHandler.java:139) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.refreshValue(ExpiringDayCache.java:86) ~[?:?]
        at org.openhab.binding.linky.internal.api.ExpiringDayCache.getValue(ExpiringDayCache.java:73) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateYearlyData(LinkyHandler.java:279) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.updateData(LinkyHandler.java:204) ~[?:?]
        at org.openhab.binding.linky.internal.handler.LinkyHandler.lambda$4(LinkyHandler.java:175) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
        at java.lang.Thread.run(Unknown Source) [?:?]
20:31:31.727 [DEBUG] [g.linky.internal.api.ExpiringDayCache] - calcNextExpiresAt result = 2024-10-14T01:00:00
20:31:31.729 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'linky:linky:local' changed from OFFLINE (COMMUNICATION_ERROR): Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-09-2024&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"} to OFFLINE (COMMUNICATION_ERROR): Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/NGYYYY/prms/xxxxxx/donnees-energie?dateDebut=01-01-2023&dateFin=13-10-2024&mesuretypecode=CONS': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"}
20:31:31.732 [DEBUG] [g.linky.internal.handler.LinkyHandler] - Update channel yearly#thisYear with NaN
20:31:31.733 [DEBUG] [ding.linky.internal.api.EnedisHttpApi] - Logout process

@lolodomo
Copy link
Contributor

lolodomo commented Oct 13, 2024

Checking the request done by the website, I agree that it is the same (except the parameter dateDebut).
We are setting no headers in the request while several are set by the website including Accept, Accept-Encoding, Accept-Language, Host, User-Agent, ... Maybe some of them are important. By the way, it would be better to provide them. Let's try it now...

@lolodomo
Copy link
Contributor

I tried with this code but same result, internal server error:

            ContentResponse result = httpClient.newRequest(url).method(HttpMethod.GET)
                    .header(HttpHeader.ACCEPT, "application/json")
                    .header(HttpHeader.ACCEPT_ENCODING, "gzip, deflate, br, zstd")
                    .header(HttpHeader.ACCEPT_LANGUAGE, "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3")
                    .header("Host", "alex.microapplications.enedis.fr")
                    .agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0").send();

Same without the Host header and same without user agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[linky] Broken again
3 participants