Skip to content

Commit

Permalink
Fix NoneType error in carelink integration (#92)
Browse files Browse the repository at this point in the history
Fixes #91

Check if user session exists
  • Loading branch information
yo-han authored Jan 2, 2025
1 parent 457b65a commit 23bf10a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions custom_components/carelink/api.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
"""
Carelink Client library
Description:
This library implements a client for the Medtronic Carelink API.
It is a port of the original Java client by Bence Szász:
https://github.com/benceszasz/CareLinkJavaClient
Authors:
Ondrej Wisniewski (ondrej.wisniewski *at* gmail.com)
Johan Kuijt (github *at* w3f.nl)
Changelog:
09/05/2021 - Initial public release (Ondrej)
06/06/2021 - Add check for expired token (Ondrej)
19/09/2022 - Check for general BLE device family to support 770G (Ondrej)
28/11/2022 - Async version of the library and console test option (Johan)
29/11/2022 - Pylint problem modifications (Johan)
Copyright 2021-2022, Ondrej Wisniewski
"""

import argparse
Expand Down Expand Up @@ -385,6 +376,9 @@ async def get_recent_data(self):
"""Get most recent data."""
# Force login to get basic info
if await self.__handle_authorization_token():
if self.__session_user is None:
_LOGGER.error("Session user is None. Cannot fetch recent data.")
return None
role = (
"carepartner"
if self.__session_user["role"]
Expand Down

0 comments on commit 23bf10a

Please sign in to comment.