Code Monkey home page Code Monkey logo

home-assistant-carelink's People

Contributors

arandall avatar increddibelly avatar sedy89 avatar timvermeulen avatar yo-han avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

home-assistant-carelink's Issues

the integration status changes to a configuration error

Hello,
after entering the data to the carelink account - the integration status changes to a configuration error. The log shows that the integration has connected to the account because you can see DEBUG (MainThread) [custom_components.carelink] Finished fetching carelink data in 26.615 seconds (success: True). I have installed HA core 2022.6.2.
Please let me know what I can do to make the integration work.

Working Great

Hi,

I have been using your integration since your initial version. The improvements you made are great.
Especially the three leading values being Last Glucose, Last Glucose Trend and Active Insuline are heavily in use for monitoring. From this week i intend to start using these values for notifications.

A smallobservation, the Active Insuline value is sometimes 'not available' even though there are values in the JSON.

Quite often the carelink service itself is not responding or the communication from the 'conduit' to the cloud is not working.
Then obviously any sensor values are defaulted or empty.
I know all the 'sensor' values are in the json for 24 hours, but i have no clue if it is possible to update the sensor 'recording' in homeassistant.

In any case, here is a screenshot of my current CGM dashboard. :)

image

Session Token - What Token to use

Hi, I have the problem that I don't know what to choose when asked for Session Token first time I set it up? I have tried once where it was working for a couple of hours and then suddenly stopped working.
I have made the logindata.json which it says in your guide.
Screenshot_1

Two-factor authentication is now mandatory.

I'd really love to get this integration up and running in my HA setup. As a type 1 diabetic for the past 43 years it would be awesome to be able to have access to my levels trhough a card. I have attemtped to install as per the instructions, but can not get past the integration log in screen in HA. I believe that this is because MFA is now compulsory on all accounts:

Minimed

The code is coming to my email account from Minimed when I hit submit, but there is no way to validate this in the integration. Is this currently being looked at?

Invalid Username/password

Integration was working fine here, but had it uninstalled a while back because of captcha issues and broken Android app.
Now when re-installing the integration I get an "Invalid username or password" error by using the same credentials as for the carelink portal.
I'm running the latest release: 2023.10.0, no MFA, "g-recaptcha-response":"abc" applied.
Log says:

2023-11-23 08:40:28.353 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_login_session() failed: exception __get_login_session() session response is not OK 400
2023-11-23 08:40:28.353 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __execute_login_procedure() failed: exception 'countrycode'

Tried AT and at for Austrian country code.

Unable to configure using UI - cl_token and cl_refresh_token fields mapped incorrectly

I tried to give this custom component a go to find that I would continually get a "Malformed access token" message in the log and an "Invalid authentication" message in the UI.

2024-03-24 05:58:06.176 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __execute_init_procedure()
2024-03-24 05:58:06.176 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _process_token_file()
2024-03-24 05:58:06.177 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-03-24 05:58:06.177 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: Malformed access token

Version: 4914186


Putting the following in the UI:

Screenshot_2024-03-24_18-02-38

I ended up with this logindata.json:

{
    "access_token": "refresh_token",
    "refresh_token": "access_token",
    "client_id": "client_id",
    "client_secret": "client_secret",
    "mag-identifier": "mag_identifier"
}

Looks like the parameters for the access and refresh tokens are swapped. A simple workaround is to enter the refresh token in the access token field and vice versa.

client = CarelinkClient(
data.setdefault("cl_token", None),
data.setdefault("cl_refresh_token", None),
data.setdefault("cl_client_id", None),
data.setdefault("cl_client_secret", None),
data.setdefault("cl_mag_identifier", None),
data.setdefault("patientId", None)
)

def __init__(
self,
carelink_refresh_token,
carelink_token,
client_id,
client_secret,
mag_identifier,
carelink_patient_id
):

Issue when adding integration with new auth process

I was able to run the auth script and got a logindata.json file on my Windows machine. On my Raspberry Pi i added the logindata.json file to the custom_components/carelink/ folder.

When adding the integration again it gives me an unknown error. When checking the log files it gives me the following output:

2024-03-06 11:54:04.671 ERROR (MainThread) [custom_components.carelink.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/carelink/config_flow.py", line 81, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/carelink/config_flow.py", line 49, in validate_input
    if not await client.login():
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 443, in login
    await self.__execute_init_procedure()
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 298, in __execute_init_procedure
    self.__tokenData = await self._process_token_file(CON_CONTEXT_AUTH)
	
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 443, in login
    await self.__execute_init_procedure()
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 298, in __execute_init_procedure
    self.__tokenData = await self._process_token_file(CON_CONTEXT_AUTH)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 434, in _process_token_file
    await self._write_token_file(token_data, filename)
  File "/home/homeassistant/.homeassistant/custom_components/carelink/api.py", line 404, in _write_token_file
    with open(filename, 'w') as f:
         ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'custom_components/carelink/logindata.json
```
`

Running HA 2024.2.3
Raspbery Pi with Python 3.12.2
Core installation

Login error

Hello,
I did the last update yesterday and it break my integration.I try to reconnect with no luck ,I try also to go back to the last update from 2023 I'm always facing login error from now.i don't know if Medtronic change something to connect but for me it doesn't work anymore.

Great work on this custom integration

Hi,

Thanks for adding this custom integration on Home assistant.
My son has been using this Diabetic pump almost two years now and all this carelink app junk of medtronic supportwise is a joke.

I was looking at the Java client of Carelink, and thinking about reverse engineering this into python and eventually putting this into home assistant. (engineering background, but facing a steep learning curve on python and Home assistant method)
And now this comes along.. talking about an early christmass present. :-)

On 19th of december i installed the integration into my home assistant instance, and hooked it up to Carelink.
Works great so far. it feels like the polling time often goes to almost 10 minutes before fresh information comes in. but i will monitor that over time.

Looking at the sensor values the Reservoire level does not match with the values is can observe on the pump and app. (half of actual)

And i was wondering the possibilities to add some more sensor values
For Dashboarding
lastSG >> current SG value : already mapped
lastSGTrend >> What is the trend of the SG value with an arrow (values are : DOWN_DOUBLE, DOWN, NONE, UP, UP_DOUBLE)
activeInsulin >> How much insuline is currently active

Daily statistics last 24 hours
averageSG : average SG value
belowHypoLimit : Percentage point time spend below Hypo Value (3,9%)
aboveHyperLimit : Percentage point time spend above Hyper Value (10,0%)
timeInRange : Percentage point time spend in between Hypo and Hyper

Planning data for replacing sensor and Infusion Set
reservoirLevelPercent : percentage of still left insuline
reservoirRemainingUnits : amount of units of insuline in the reservoir
medicalDeviceBatteryLevelPercent : Battery level of the sensor
sensorDurationHours : How many hours remaining on current sensor (countdown of 7 days to zero

Again thanks ever so much for your work already done.. And if there is anyway i can help, by either testing or otherwise. Let me know.

No devices or entities/ Cannot access local variable 'timezone_map'

When I log in, it says no devices or entities, and it gives an error Cannot access local variable 'timezone_map' where it is not associated
with a value

my logs:

Logger: custom_components.carelink
Source: custom_components/carelink/init.py:167
Integration: carelink
First occurred: 18:36:35 (16 occurrences)
Last logged: 18:49:42
Unexpected error fetching carelink data: cannot access local variable 'timezone_map' where it is not associated with a value

Traceback (most recent call last):
File "/config/custom_components/carelink/init.py", line 152, in _async_update_data
if "clientTimeZonseName" in recent_data:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

During handling of the above exception, another exception occurred:

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 167, in _async_update_data
"Can not set timezone to %s. The error was: %s", timezone_map, error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'timezone_map' where it is not associated with a value

Integration stopped working & cannot login anymore: 'auth_tmp_token' error

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] ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 1148, in __getitem__ raise KeyError(name) KeyError: 'auth_tmp_token' 2023-08-19 00:32:21.173 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Carelink' for carelink integration not ready yet: 'auth_tmp_token'; Retrying in background

Cant sign-in

I was having issues with my account and had to reset my password in CareLink itself. This was done succesfully and now can sign-in through the Browser, but after deleting, upgrading CareLink with HACS i'm not able to setup the CareLink integration anymore. I have enabled Debug logging and see the following:

2023-06-28 14:32:35.898 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_login_session() failed: exception __get_login_session() session response is not OK 504
2023-06-28 14:32:35.899 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __execute_login_procedure() failed: exception 'sessionID'

This might have to do with the switch of the Auth server as suggested in the latest release (3 hours ago)?

Home Assistant 2023.6.3
CareLink: 2023.6.5

Wrong last glucose level mmol/l

I'm running the latest beta version 2024.2.0.1-rc1 but the problem is that it types out the last glucos level as exampel 117,11 mmol/l when it is 11,7 mmol/l

Error with setting up Integration

Running latest version through HACS.

When setting up the Integration I enter my Username/Password and CountryCode (nl). When Trying to Save/Connect it hits me directly with an "Unknown error".

Running HA 2023.5.4
Log gives me:
`Logger: custom_components.carelink.config_flow
Source: custom_components/carelink/config_flow.py:35
Integration: carelink
First occurred: 12:53:37 (2 occurrences)
Last logged: 12:56:37

Unexpected exception
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/carelink/config_flow.py", line 61, in async_step_user
info = await validate_input(self.hass, user_input)
File "/home/homeassistant/.homeassistant/custom_components/carelink/config_flow.py", line 35, in validate_input
data["username"], data["password"], data["country"], data["patientId"]
KeyError: 'patientId'`

Carelink Download Interval

Hi,
I currently use the rc1 beta (including the nightscout updater). It works nicely, but I noticed that the new sensor values do not get fetched in regular intervals. To see this, I added a template-sensor with the following definition:

{{ ( as_timestamp(states.sensor.last_glucose_update.last_changed) - as_timestamp(states.sensor.last_glucose_update.state) ) | round(0)}}

and what I observe is this:
image

This means that the delay between the SGV reading (as reported by Carelink) and the download time (as the time of entering the HA database) vary between roughly 40 and 100 seconds.

1st question: Is there some logic behind the fetching/downloading time of this integration?
2nd: Why is it not a fixed interval of 300 sec, as we know that the data comes in at that rate?
3rd: somehow related, I'd also like to see #4 being implemented.

Thanks for your time spend on this extension :)

Adding support for Banner Tag

The Carelink JSON data has the support for Certain Banner Messages to be shown, when they are relevant.
On the actual pump these are the semi permanent messages that require an action or display the special condition of the patient at that moment.

The request is if it would be possible to add the Banner Tag as a mapped sensor value.
By default there is no value present, but in case of the below mentioned enumerations a human readable value can be shown.

The normal state of the pump in JSON data is like this:
"pumpBannerState": [],

When in a special state is shows like this:
"pumpBannerState": [ { "type": "SUSPENDED_BEFORE_LOW" } ],

In the Java Client there was an actual breakdown of all the known messages that could be present.
I took the effort to translate to actual messages being used on the pump in english and dutch.

Type value is an enumeration of specific values (in english)
Value;Nice Name;Nice Name Dutch
DUAL_BOLUS;Dual Wave Bolus;Dual Wave Bolus
SQUARE_BOLUS;Square Wave Bolus;Square Wave Bolus
LOAD_RESERVOIR;Load Reservoir;Reservoir Laden
SUSPENDED_ON_LOW;Suspend on low;Stop bij laag
SUSPENDED_BEFORE_LOW;Suspend before low;Stop voor laag
DELIVERY_SUSPENDED;Delivery suspended;Basaal gestopt
BG_REQUIRED;BG required;BG Benodigd
PROCESSING_BG;Processing BG;Verwerken BG
WAIT_TO_ENTER_BG;Wait to enter BG;Wacht invoeren BG
TEMP_TARGET;Temporary Target;Tijdelijke streefwaarde
TEMP_BASAL;Temporary Basal;Tijdelijke basaal
NO_DELIVERY;No delivery;Geen basaal
CALIBRATION_REQUIRED;Calibration required;Kalibratie vereist

'NoneType' object has no attribute 'setdefault'

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 :-(

Token refresh

Hello, Could you help me pls. A started to use this Carelink integration, but about every 4-5 days I have to refresh the token, if not all the data will be "unavailable". Am I doing soemthing wrong? Thanks a lot!

Python script error

Please help:
I am getting a lot of errors when running the script. How should I deal with that?

PS C:\Users\night> python carelink_carepartner_api_login.py
  File "C:\Users\night\carelink_carepartner_api_login.py", line 7
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax

Re-downloaded and re-run:

PS C:\Users\night> python carelink_carepartner_api_login.py
Traceback (most recent call last):
  File "C:\Users\night\carelink_carepartner_api_login.py", line 49, in <module>
    from seleniumwire import webdriver
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\webdriver.py", line 28, in <module>
    from seleniumwire import backend, utils
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\backend.py", line 4, in <module>
    from seleniumwire.server import MitmProxy
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\server.py", line 5, in <module>
    from seleniumwire.handler import InterceptRequestHandler
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\handler.py", line 5, in <module>
    from seleniumwire import har
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\har.py", line 11, in <module>
    from seleniumwire.thirdparty.mitmproxy import connections
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\thirdparty\mitmproxy\connections.py", line 10, in <module>
    from seleniumwire.thirdparty.mitmproxy.net import tls, tcp
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\thirdparty\mitmproxy\net\tls.py", line 17, in <module>
    from seleniumwire.thirdparty.mitmproxy.contrib.kaitaistruct import tls_client_hello
  File "C:\Users\night\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\seleniumwire\thirdparty\mitmproxy\contrib\kaitaistruct\tls_client_hello.py", line 10, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'

Most values don't update

Thanks for making this integration!

I've installed the integration and I'm able to authenticate and see my values just fine. The problem I'm having is that nearly all values aren't updated continuously, unless I reload the integration manually. The only entities that do get continuous updates are sensor.last_glucose_level_mmol and sensor.last_glucose_level_mg_dl. All the other ones are just stuck on the value at the time the integration was last reloaded.

I've looked at the logs, and the DEBUG (MainThread) [custom_components.carelink] _async_update_data: logs contain accurate, up to date information. So the _async_update_data function seems to be working fine. But for one reason or another, only those two keys are then propagated properly into my Home Assistent on each poll.

Any idea what could be causing this?

Retrying setup: 'dateTime'

I have an issue. Component cannot be initialized.

Error in the logs:

Logger: custom_components.carelink
Source: custom_components/carelink/init.py:412
Integration: carelink
First occurred: 15:04:37 (13 occurrences)
Last logged: 15:23:36

Unexpected error fetching carelink data: 'dateTime'
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 287, in _async_update_data
last_meal_marker = get_last_marker("MEAL", recent_data["markers"])
File "/config/custom_components/carelink/init.py", line 410, in get_last_marker
sorted_array = sorted(
File "/config/custom_components/carelink/init.py", line 412, in
key=lambda x: convert_date_to_isodate(x["dateTime"]),
KeyError: 'dateTime'

Home Assistant 2023.5.2
Frontend 20230503.3 - latest

Integration error with 2023.12.1

Updated to the new 2023.12.1 and followed the instructions: created a follower account, logged in and copied and pasted temp auth token.
Debug shows the following: (time zone UTC+1)

2023-12-28 14:10:46.911 DEBUG (MainThread) [custom_components.carelink.api] Carelink country: at
2023-12-28 14:10:46.911 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: Initial token expires in 1954s (Thu Dec 28 13:43:21 UTC 2023)
2023-12-28 14:10:46.927 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_my_user()
2023-12-28 14:10:46.927 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:47.339 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_my_profile()
2023-12-28 14:10:47.339 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:47.492 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_country_settings()
2023-12-28 14:10:47.492 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:47.676 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_monitor_data()
2023-12-28 14:10:47.676 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:47.868 DEBUG (MainThread) [custom_components.carelink.api] Carelink country: at
2023-12-28 14:10:47.868 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: Initial token expires in 1953s (Thu Dec 28 13:43:21 UTC 2023)
2023-12-28 14:10:47.883 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_my_user()
2023-12-28 14:10:47.883 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:48.073 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_my_profile()
2023-12-28 14:10:48.073 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:48.304 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_country_settings()
2023-12-28 14:10:48.304 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:48.471 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_monitor_data()
2023-12-28 14:10:48.471 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:48.640 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_connect_display_message()
2023-12-28 14:10:48.640 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2023-12-28 14:10:48.790 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: 400
2023-12-28 14:10:48.790 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data() failed: exception __get_data() session get response is not OK400
2023-12-28 14:10:48.790 DEBUG (MainThread) [custom_components.carelink] Using timezone Europe/Vienna
2023-12-28 14:10:48.791 DEBUG (MainThread) [custom_components.carelink] Using timezone Europe/Vienna
2023-12-28 14:10:48.791 ERROR (MainThread) [custom_components.carelink] 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 300, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/carelink/init.py", line 172, in _async_update_data
recent_data["lastSG"] = recent_data.setdefault("lastSG", {})
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'setdefault'
2023-12-28 14:10:48.795 DEBUG (MainThread) [custom_components.carelink] Finished fetching carelink data in 0.927 seconds (success: False)

[FR] Allow to update token via UI

Today, if the token expires, I have to update the cookie.txt file. Annoying if I have no direct access to HA server

It would be useful to be able to update the token via the user interface.

BTW, Thanks for this integration, I'm able to see the carelink data on my smartwatch ;) ( Carelink EU / MFA with follower account )

No readings

Hello. I'm in the US and tried using this HA component, but when I setup the "device" in HA, it pulls the patient correctly, shows me info about the pump, but there are no CGM readings (Last glucose level mg/dl = unknown).

I tried logging in with follower account and patient account and same exact results.

Any thoughts?

Screenshot 2024-01-14 025501

Wrong values since last upate

Updated to the latest version and re-integrated:

  • pump_battery_level sensor = 0%
  • all reservoir sensors = 0
  • active_insulin sensor = -1
  • duration_hours sensor = 0

These are some of those I monitor. There are more that shows 0.

This might be due to an update issue. I did not receive any update since I re-integrated an hour ago. Re-loading the integration does not update the sensor values.

Restarting now for debug.

exception __get_data() session get response is not OK204

Dear Yo-ha!
Thank you for your work!
I have a little issue.
The new integration (2024.3.1) working fine, but no data is received.
I tried to write the optional PatientID, too.
The oldiest integration (2024.1.0) brought the informations.

The debug log:

2024-04-25 18:04:04.135 WARNING (SyncWorker_6) [homeassistant.loader] We found a custom integration carelink which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-25 18:04:20.299 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __execute_init_procedure()
2024-04-25 18:04:20.299 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _process_token_file()
2024-04-25 18:04:20.302 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-04-25 18:04:20.302 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_config_settings()
2024-04-25 18:04:21.377 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: User region: EU
2024-04-25 18:04:21.466 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_my_user()
2024-04-25 18:04:21.467 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2024-04-25 18:04:21.467 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __handle_authorization_token()
2024-04-25 18:04:21.467 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-04-25 18:04:21.586 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __getPatients()
2024-04-25 18:04:21.586 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2024-04-25 18:04:21.586 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __handle_authorization_token()
2024-04-25 18:04:21.586 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: Found patient **redacted** (**redacted**)
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __handle_authorization_token()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_connect_display_message()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __handle_authorization_token()
2024-04-25 18:04:21.637 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: _get_access_token_payload()
2024-04-25 18:04:21.740 DEBUG (MainThread) [custom_components.carelink.api] Carelink API: __get_data() failed: exception __get_data() session get response is not OK204
2024-04-25 18:04:21.741 DEBUG (MainThread) [custom_components.carelink] Using timezone Europe/Budapest
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] Using timezone Europe/Budapest
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] the marker with type 'MEAL' could not be tracked correctly. Check if your Carelink data contains a key with the name list index out of range, it seems to be missing.
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] the marker with type 'INSULIN' could not be tracked correctly. Check if your Carelink data contains a key with the name list index out of range, it seems to be missing.
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] the marker with type 'AUTO_BASAL_DELIVERY' could not be tracked correctly. Check if your Carelink data contains a key with the name list index out of range, it seems to be missing.
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] the marker with type 'AUTO_MODE_STATUS' could not be tracked correctly. Check if your Carelink data contains a key with the name list index out of range, it seems to be missing.
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] the marker with type 'LOW_GLUCOSE_SUSPENDED' could not be tracked correctly. Check if your Carelink data contains a key with the name list index out of range, it seems to be missing.
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] _async_update_data: {'client_timezone': zoneinfo.ZoneInfo(key='Europe/Budapest'), 'pump_battery_level': None, 'conduit_battery_status': None, 'sensor_battery_level': None, 'sensor_duration_hours': None, 'sensor_duration_minutes': None, 'reservoir_level': None, 'reservoir_amount': None, 'reservoir_remaining_units': None, 'last_sg_trend': None, 'time_to_next_calib_hours': None, 'active_insulin': None, 'active_insulin_attributes': {}, 'last_alarm': None, 'last_alarm_attributes': {}, 'active_basal_pattern': None, 'average_glucose_level_mgdl': None, 'below_hypo_limit': None, 'above_hyper_limit': None, 'time_in_range': None, 'max_auto_basal_rate': None, 'sg_below_limit': None, 'last_marker_meal': None, 'last_marker_insulin': None, 'last_marker_auto_basal_delivery': None, 'last_marker_auto_mode_status': None, 'last_marker_low_glucose_suspend': None, 'binary_sensor_pump_comm_state': None, 'binary_sensor_sensor_comm_state': None, 'binary_sensor_conduit_in_range': None, 'binary_sensor_conduit_pump_in_range': None, 'binary_sensor_conduit_sensor_in_range': None, 'pump serial': None, 'pump name': 'Name Unvailable', 'pump model': None, 'app_model_type': None}
2024-04-25 18:04:21.742 DEBUG (MainThread) [custom_components.carelink] Finished fetching carelink data in 1.443 seconds (success: True)

What could be the problem?
Thank you for your help!

incorrect timezone setting in nightscout uploader?

Hello again,
I'm currently in a different timezone and note some weird behavior with this integration. The first part of the pipeline works as expected: The SG data is correctly uploaded by my pump, and also correctly downloaded by the HA integration. All timestamps are correctly implemented, independent of the local settings of my computer when checking out the sensors in HA.

However, the second step, uploading to Nightscout, seems to ignore the timestamps. The data is uploaded, but when I checkout my nightscout page, I see it not with respect to the timezone, but as if it was uploaded from my home-timezone, i.e. I see a warning "9 hours ago" (as I'm 9 hours earlier than my home timezone).

I tried understanding the nightscout-uploader.py and noticed that, in principle, the timezones are implemented there, but could not understand where this error is coming from.

Thanks for you time :)

Gets initial values and that’s it - never updates

Even after reloading a few times after 15hrs the values just don’t change - she’s good with her blood sugars but not that good lol. Maybe new carelink software etc no longer works with your pull/polling methods?

Download data history?

Hi,
I just started using this custom component and recognized, that it doesn't fetch data "of the past".
in particular, I had some time today where my phone (that uploads the pump data to the medtronic servers) wasn't connected to the internet. That resulted in gaps in this components sensor (see screenshot).
Screenshot_20240130-222507

Would it be possible to check for gaps and download the glucose history from carelink?

Although I'm not familiar with code for web applications, I know some python.. Could try helping, if someone can give a starting point.

Best,
trenar

Auto update token

Is it possible to auto update token if we insert username/pw and country? Or is it possible to make a script in HA for this?

Integration stopped working

Today the integration stopped working and wanted a re-setup.
But my credentials won't be accepted anymore. Authentication within Minimed app and on carelink.minimed.com is still working.
Maybe Medtronic changed something with anthentication ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.