-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Fixes for change in Enedis API on 2024 December 20 #17945
Conversation
Thank you @lo92fr , I will review and test. |
I still have Java 17 and Java 21 on my dev PC so it should be easy to build a JAR for Java 17. |
@lolodomo Hopefully it is just:
https://community.openhab.org/t/openhab-5-x-snapshot-requires-java-21/160890/5 |
@lo92fr : does not work for me => Error requesting 'https://alex.microapplications.enedis.fr/mes-mesures-prm/api/private/v1/personnes/xxxxx/prms/yyyyy/donnees-energetiques?mesuresTypeCode=ENERGIE&mesuresCorrigees=false&typeDonnees=CONS&dateDebut=2023-01-01': {"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"} Will see if it work in next tries (next hours). |
It still work on my side, strange. Laurent. |
3 letters then 3 numbers and then 3 letters. |
Yes, I have the same page on their website. |
Now the binding is working! Even after I disconnect from the website in my browser. |
updateState(PEAK_TIMESTAMP, new DateTimeType( | ||
days.datas.get(days.datas.size() - 1).dateDebut.atZone(this.timeZoneProvider.getTimeZone()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was changed very recently, just before releasing 4.3. We don't need to pass a ZonedDateTipe; DateTimeType just needs an Instant as parameter. So you do not need TimeZoneProvider .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lolodomo,
I'm not sure to understant. Do you say to use the DateTimeType constructor that take an instant, something like this.
updateState(PEAK_TIMESTAMP,
new DateTimeType(days.datas.get(days.datas.size() - 1).dateDebut.toInstant(zoneOffset)));
The matter is that I still need to find a zoneOffset in this case.
The Enedis API return a LocalDateTime at offset of the current zone.
The DateTimeType if I undestand correctly want a universal time.
So somewhere we need to convert from local to universal using a timezone ?
Laurent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlaur is our specialist with date. Please advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If days.datas.get(days.datas.size() - 1).dateDebut
is a LocalDateTime
, the implementation is already correct. If it is an Instant
there is no need to convert to ZonedDateTime
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the implementation is already correct
@jlaur : you mean @lo92fr proposed code is correct ?
I am a little lost, why should we consider the timezone setup in server ?
Imagine that for a strange reason I setup timezone in OH server to UTC+5. I am convinced Enedis provides dates in France timezone, that is UTC+1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jlaur,
No there is no way to configure the home location / time-zone in the eneids account.
I think this is a hidden fixed value that is link to your PDL (Point of Delivery) that is linked to your postal address.
So I think the best is to assume that the api just return a local Datetime, and that the openhab server is on the same timezone.
The only scenario I can see that can be bad is someone having two different house : let say one in France, and one in another timezone like Guadeloupe, and that at the same time will use only one openhab instance for the two house.
In this case, result can be wrong.
Laurent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't the timezone be a configuration setting of the PDL thing ? Defaulted to France/Paris ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the default should then be openHAB time-zone rather than France/Paris, given what @lo92fr wrote about the service probably using time-zone of PDL. But since it's not documented or proven, I guess it doesn't matter much, as long as it can be overridden by configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix fails for me. |
While I installed 4.3.1, I updated again the linky bundle and it seems to work well yesterday and also today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments related to the time-zone commit. The I18 properties file should also be regenerated.
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
My comments are resolved, but I have not reviewed this PR, so @lolodomo will be needed for finalizing the review and merging the PR. |
The major problem is that unfortunately this fix does not work well ! Am I alone with this PR not working more than one day ? |
Have to said that I'm not totally sure myself if the fix is ok or not. @lolodomo : what error do you have after one day, an http 500 Internal Error ? What I try so far if to make the refresh more frequent, I see that if I change the refresh frequence from 24h to 3h, I can trigger the error as weel after only 3 hours. I've also try in this case to clear all cookie, and redo the connectionInit phase, but this don't seem sufficient to fix the error. So I thing there is something that expire after some session time, and stay in memory, and that is not reinitialized correctly. I will continue to narrow done this issue in the next few days, and will tell you if I find something. Laurent. |
{"message":"Internal server error. Please try again","code":"INTERNAL_SERVER_ERROR"} |
Hello all, @lolodomo Perhaps find a fix on this new error. My assomption is that the new website implementation keep some state data, and invalidate them after a few hours. I've doned some test on v2 branch, seems to fix the problems on my side. Laurent. |
@lo92fr : can you please rebase your branch so that we can compile it again ? |
cd8015d
to
f1dba4f
Compare
Helo @lolodomo, Done the rebasing just right now. Laurent. |
I just build and deploy the last jar and yes you're right, it still does not work, always the same internal server error. |
- URL for data is now mes-mesures-prm and not mes-mesures. - Dto format have changed : mainly merge data & date, field renaming, and moving. - Some changes on date format. Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
f1dba4f
to
f8c7600
Compare
Signed-off-by: Laurent ARNAL <[email protected]>
Hello @lolodomo, Just to be sure to understand : you have the 500 Internal Server errors just after starting the binding, or on the nightly refresh at 1'oclock ? On my side, it's working since several day without error, refreshing data correctly every day. Also, I have to done some modifications on the ExperingDayCache. So I've made some modification on the logic of the Cache : if I detect that data is incomplete, I retry to read data after the REFRESH_INTERVAL_IN_MIN (120mn). So it will try at 1'oclock, 3'oclock, 5'oclock until he get the correct data. I've also modifify the nextExpireAt logic a little, the idea is not to do all the request at the exact same hours for all users. But to randomize them a little to distribute the request around the central hour. This change is on my last commit in the fix branch. I've backport them this morning from v2. Laurent. |
Signed-off-by: Laurent ARNAL <[email protected]>
…licate whith check already done in getConsumptionAfterChecks Signed-off-by: Laurent ARNAL <[email protected]>
…on't need it anymore Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
Hello @lolodomo, @jlaur, @clinique, Just a little news about the fix. I've reverted some of my last change on ExperingDayCache as I realized that the missingData logic I add was duplicate with check in getConsumptionAfterChecks. I've also modified condition in getMetaData so we always call the getPrmInfos / getPrmDetails even if we already have the information. With this last fix, it solve the 500 nightly error on my side. I've deploy the branch on my production openhab, and it now working well since 2 day without 500 error, and getting fresh value every night :) I will keep it until monday to be sure everything is okl, but I think you perhaps can get another try to this new version. Laurent. |
Thank you Laurent, I just deployed the new version and the binding is ONLINE. I will see if it survives at least 3 days. I am starting a new review of the PR. |
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
Will default to openHAB default timezone. | ||
You will | ||
need to change this if your Linky is located in a different timezone that your openHAB location. | ||
You can use an | ||
offset, or a label like Europe/Paris</description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a remark: the line cuts are relatively strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fix in next commit
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/i18n/linky.properties
Show resolved
Hide resolved
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml
Show resolved
Hide resolved
...nhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java
Outdated
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Outdated
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Outdated
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Laurent ARNAL <[email protected]>
Signed-off-by: Laurent ARNAL <[email protected]>
Hello @lolodomo, I've fixed the issue of your last review. Laurent. |
@lo92fr : please rerun the i18n tool to take into consideration your change of label. The binding was still "alive" this morning. |
Signed-off-by: Laurent ARNAL <[email protected]>
Fixes for Linky Enedis December web site change
This pull request is about fixing the linky addon after the change that was made on Enedis side to the Web Site.
This is linked to issue:
#17936
Description
Mainly, changes are :
- URL for data is now mes-mesures-prm and not mes-mesures.
- Dto format have changed : mainly merge data & date, field renaming, and moving.
- Some changes on date format.