-
-
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] Yet another website underlaying API modification #17538
Conversation
Signed-off-by: Gaël L'hopital <[email protected]>
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 <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
I will test this evening and finish the review. |
...nhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java
Show resolved
Hide resolved
...rg.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/PrmDetail.java
Show resolved
Hide resolved
...rg.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/PrmDetail.java
Outdated
Show resolved
Hide resolved
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Show resolved
Hide resolved
@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:
If I uninstall the bundle and then put the jar file in folder addons:
|
Please upgrade jsoup in a separate PR. I am now trying to remove jsoup upgrade to be able to test the fix! |
This will also facilitate backport to branch 4.2.x. |
...hab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/LinkyHandler.java
Outdated
Show resolved
Hide resolved
If I remove jsoup upgrade, I am able to use the binding again and it is alive (ONLINE) again, bravo. |
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 <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Signed-off-by: Gaël L'hopital <[email protected]>
Changing this dependency seems to prevent the update of the binding in an existing OH setup. |
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. |
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); |
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.
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.
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.
No problem, I'm not in a hurry.
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.
Values for yesterday, current week, last week, current month and last month are correct today.
Let's see tomorrow.
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 |
Still not working for me at Midday.. Can you try on your side ? |
...penhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/api/EnedisHttpApi.java
Show resolved
Hide resolved
Tested on my side, the same today. Weird thing is the same query in the browser works without issue. |
Now it works... |
You may try to tace it in debug mode to understand where it's blocked. |
Here are my logs:
|
Checking the request done by the website, I agree that it is the same (except the parameter dateDebut). |
I tried with this code but same result, internal server error:
Same without the Host header and same without user agent. |
Hello Gaël , how can we explain that it works for you and not for me ? How can we progress ? |
Sorry Laurent, right now I don't have a clue. Maybe we can ask some other users to test the jar and give us their feedback ? |
Ok. Can you prepare that and communicate on the community forum so that we have other feedbacks? |
Done here |
logger.debug("Step 4 : auth2 - send the auth data"); | ||
result = httpClient.POST(authenticateUrl).header(HttpHeader.CONTENT_TYPE, "application/json") | ||
logger.debug("Step 4: auth2 - send the auth data"); | ||
result = httpClient.POST(authenticateUrl).header(HttpHeader.CONTENT_TYPE, MediaType.APPLICATION_JSON) |
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.
I'm not sure if this could cause more than one Content-Type
header, which could be rejected by some webservers. The safer approach might be to provide the content-type below instead of manually adding the header:
.content(new StringContentProvider(gson.toJson(authData), MediaType.APPLICATION_JSON))
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.
Thank you for your suggestion but the binding does not break at this step.
@clinique : very strange but very good news. I just installed the last snapshot and as soon as I updated the linky bundle, it started to work. Even after an OH restart, it is still OK. It is as if your fix requires a recent change in core... Strange... |
It is again KO today! |
On my side, one day working one day not... :-( |
Hello @clinique, Hello @lolodomo, Sorry for it, but I’ve don't see you were working on your side on the same issue. I've hit the same internal server error as you. I've found two different things: 1/ The Enedis site seems now to check / be dependent of the user agent, I've to set a fixed user agent to correct the error. 2/ It's seeming that we need a second cookie to be there to make sure we don't it the 500 error. This cookie can be obtains making a call to the URL: /mon-compte-client/api/private/v1/userinfos. I've made this on the authentication part, as a step 7. This changes is implements on the linkyv2 branch. @clinique : I've not fully read your PR so far. Specially your modification on the URL: /mes-prms/api/private/v2/personnes/%s/prms that I've not have on my side. One note about linkyv2 current state : It's still WIP. Also, I still have some initialization error with 4.3 milestone on Dev Environment that I've don't understand so far, and that make my development effort hardier. What I find currently:
Also, nothing to go with Linky binding, but I’ve also realized that on my production environment, that javascript rule take forever to load: around 5 minutes after the start of openhab. I think that javascript rules now are load only after all binding are initialized? and on my setup, I have a lot of bindings, and somes take a long time to come online. Laurent. |
@lo92fr bravo 👍 |
Signed-off-by: Gaël L'hopital <[email protected]>
I just tried with the following changes but for me the result is still the same: error 500.
|
Let see if the retries at 11h and 12h will succeed... |
It's strange, was working on my side this morning. Laurent. |
Let me know if you can't make it work. Laurent. |
@lolodomo, @clinique : hum, was working this morning, but not work anymore now ! I've hit the error on the URI : https://alex.microapplications.enedis.fr/mes-mesures/api/private/v1/personnes/undefined/prms/xxxx/courbe-de-charge?dateDebut=03-11-2024&dateFin=09-11-2024&mesuretypecode=CONS. Laurent. |
The site seems to came back online. Laurent. |
Yes, my thing is now ONLINE. @clinique : same for you ? |
Thanks you Laurent |
Resolves #17513