Closed GertVanderstukken closed 1 year ago
Just to know: Is anybody else experiencing the same issue? Or is it just me :( ?
Hi @GertVanderstukken. I've never seen this issue before. What version of Home Assistant are you using and what version of this integration? Are they both up to date?
Hey, strange...
I'm on the latest version of everything:
Home Assistant 2023.8.3 Supervisor 2023.08.1 Operating System 10.5 Frontend-versie: 20230802.1 - latest
HACS: 1.32.1 Carelink Integration: 2023.7.0
OK, I did some more testing on a Home-Assistant instance I had powered off for some time, that is based on docker.
When I start it with a container running Home-Assistant version 2023.5.3, it runs OK. When I start it using a 2023.5.4 container, it fails.
Stopping and restarting 2023.5.3 => OK again.
What version of Home Assistant are you running ?
I just installed a complete new Home Assistant server, installed HACS & Carelink integration => not working. Very strange. Nobody else with this problem?
I'm running the integration in the latest available version now. Maybe I can test some other versions tonight, I know there are some changes done to Home Assistant this year that had an impact on the integration but they are never in minor releases (e.g. 2023.8.2) but only in the major ones (e.g. 2023.8.0).
There you got seems to occur when no session is setup with metronic after login. Not sure why this only seems to happen to you.
I can confirm i have the same issue, also the temp token issue.
Running the HA Core 2023.8.3 version on Python 3.11 on Raspbian. If you need more info let me know i'm happy to do some debug logging
Jup, got it now too after a reboot. Not sure where this comes from but now I have a starting point at least.
At least I'm not alone anymore. Welcome to the club :)
Same issue Home Assistant 2023.8.3 Supervisor 2023.08.1 Operating System 10.4 Frontend 20230802.1 - latest
I did a quick test with the original client lib I used (https://github.com/ondrej1024/carelink-python-client) and it has the same problem. I guess something changed in the login process again.
It can also have something to do with the python version 3.11. Is there anyone still running on python 3.10 and running a working installation of the latest version of this integration?
User-Agent data was modified in the xDRIP application and it started logging in correctly: https://github.com/NightscoutFoundation/xDrip/commit/22954b7233e6070b0a758f21cf06e234eae2c0e7
OK, I found a way to make it work.
in api.py, I changed line 94:
self.__common_headers = {}
into:
self.__common_headers = {
"Accept-Language":"en;q=0.9, *;q=0.8",
"Connection":"keep-alive",
"sec-ch-ua":"\"Google Chrome\";v=\"115\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"115\"",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
}
rebooted and all started working.
I based myself on "carelink_client.py" - line 78 (https://github.com/ondrej1024/carelink-python-client).
Also in there, they mention:
# 09/05/2023 - Fix connection issues by removing common http headers
But....
I'm NOT a developer, so I'm not sure if this is the right thing ...
I corrected the code you wrote in the api.py file and everything works fine now - good job.
Hmmm. These headers are removed in pr #39 because it made the login not work. Not completely sure if this is the final solution.
hi @yo-han , as @niemczuk mentioned, a very similar change was taken into xdrip to fix the communication after the latest carelink server update https://github.com/NightscoutFoundation/xDrip/pull/3029. They did not just add back the common headers, but they updated the chrome user agent to the latest version number. Seems to be required after the latest medtronic server update.
Yes I noticed. But what I don't understand is why a version of a browser would be a factor for Medtronic to not let someone login. This is the second time these headers are the source of issues where users cannot login anymore. For now we can restore them, but I would like to know what the real reason is they need to be updated.
Why would Chrome/112 be an issue? It's a release from may this year. A version like Chrome/87 would make more sense.
I made a beta release with a possible fix. If anyone wants to test it please activate beta releases for this integration in Home Assistant and pull new updates.
https://github.com/yo-han/Home-Assistant-Carelink/releases/tag/2023.8.0-b1
Works for my install.
Ps my theory is that Medtronic was implementing updates on the Auth services. But the last Weeks there were quite a few outages, so maybe they opted to go back to something more reliable..
I made a beta release with a possible fix. If anyone wants to test it please activate beta releases for this integration in Home Assistant and pull new updates.
https://github.com/yo-han/Home-Assistant-Carelink/releases/tag/2023.8.0-b1
The beta also solves the issue for me
Allright. A new release is available for everyone now. It worked for me I several version too so this must be it for now.
Yes, the new release is working for me. Thanks!
The integration suddenly stopped working somewhere yesterday. I have to say that I also had some issues on the app on my mobile for some time before that, so I figured it to be a general problem @ Medtronic.
Then the app on my mobile started working again, however the HA integration was not.
I tried to remove and re-add the integration, but when I try to complete the credential window, I get "bad username/password" (but I'm "sure" it's OK).
Anybody else with this problem?
This is in the logs: ` 2023-08-19 00:32:21.165 ERROR (MainThread) [custom_components.carelink] Unexpected error fetching carelink data: 'auth_tmp_token' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/carelink/init.py", line 149, in _async_update_data recent_data = await self.client.get_recent_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/carelink/api.py", line 468, in get_recent_data if await self.__get_authorization_token() is not None: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/carelink/api.py", line 430, in __get_authorization_token auth_token = self.async_client.cookies[CARELINK_AUTH_TOKEN_COOKIE_NAME]