Closed hhuitema closed 1 year ago
Yup. I can see the same error now. Will take a look at it when I can.
The integration is working fine nonetheless. Is your not? The error is something with timezones in different formats through out the world. I don't think it has something to do with app changes.
for me there is no data at all.. but that might be related to having a dedicated 'follower' user as a carelink account.
By the way the python client now has an update that you might need to integrate. There is a new variable to use. (patientId username) link to the issue
From home assistant logs. I hope it helps troubleshooting
Deze fout is ontstaan door een aangepaste integratie.
Logger: custom_components.carelink Source: custom_components/carelink/init.py:135 Integration: carelink First occurred: 13:19:01 (315 occurrences) Last logged: 20:41:50
Unexpected error fetching carelink data: 'NoneType' object has no attribute 'setdefault' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/carelink/init.py", line 135, in _async_update_data recent_data.setdefault("clientTimeZoneName"), "Europe/London" AttributeError: 'NoneType' object has no attribute 'setdefault'
Pulled from the logs at debug level.. 2023-05-25 07:31:54.947 INFO (MainThread) [httpx] HTTP Request: GET https://carelink.minimed.eu/patient/monitor/data "HTTP/1.1 200 OK" 2023-05-25 07:31:54.948 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: get_connect_display_message() 2023-05-25 07:31:54.948 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: get_data() 2023-05-25 07:31:55.405 INFO (MainThread) [httpx] HTTP Request: POST https://clcloud.minimed.eu/connect/carepartner/v6/display/message "HTTP/1.1 400 Bad Request" 2023-05-25 07:31:55.408 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: 400 2023-05-25 07:31:55.408 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data() failed: exception __get_data() session get response is not OK400 2023-05-25 07:31:55.408 ERROR (MainThread) [custom_components.carelink] Unexpected error fetching carelink data: 'NoneType' object has no attribute 'setdefault'
I got the carelink python code running on my desktop by adding the patient username to the userjson
# Build user json for request userJson = { "username":username, "role":role, "patientId":patient } requestBody = json.dumps(userJson)
a quick hack could be to introduce a new variable to allow data retrieval for 1 patient. we would need a config variable for the integration then.
in future the integration has a whole new root level. Instead of the pump being the root, the patient would be the new root, where there can be up to four patients. However i can live with a restriction of a single patient.. ;-)
Did a manual adjustment in api.py locally on my HA instance, and it works immediately..
Indeed, I changed this under api.py: user_json = {"username": username, "role": role} to user_json = {"username": username, "role": role, "patientId":"TheUserNameAsSeenunderSettingsinCareLinkConnect"}
And it worked...
Indeed, line 350 in api.py.
The whole community behind the Java coding and the Python port on which this integration is relying on is debating how to implement. Making it single patient configurable or as medtronic is exposing it, enabling for 4 patients. Regardless, for me it now works and in most cases a single patient will do just fine.
Looks good guys. Is there anyone who can make a PR of it. I'm happy to to approve it. Otherwise it make take a little while because I'm quite busy with work and home stuff at the moment.
Thanks to your research a fix for the Carelink Partner accounts was not that hard to make. I made a pre-release available for testing here.
I tested with a running integration with a normal account. Removed the integration and logged in with a partner account. Both worked fine. But I would love to here from more people that it is working well before releasing it to a greater group of people.
I was running with your code in the train yesterday afternoon, so i will be curious to compare my hacky solution with yours.. :) In the meantime i installed the new RC version and it works immediately, including the hardware details being exposed.
One beautification thingy, the new field to configure does not have a title, something to add for the final version. ;)
I can't reproduce the missing field label.
I released a new version with Carelink Partner support and some minor fixes and translations.
This issue is stale because it has been open for 30 days with no activity.
Confirmed to be working, let's close this ticket
Since 24-5-2023 this error is starting to occur in the log of HA. Not accidentally when looking in the Carelink APP (Ios or Android) i can now select which person to follow. (up to 4 people)
So i think there might be some technical issues with the API url, and retrieved data. For now disabling the Integration :-(