diff --git a/docs/Freestyle drawings.pptx b/docs/Freestyle drawings.pptx deleted file mode 100644 index 5026a74..0000000 Binary files a/docs/Freestyle drawings.pptx and /dev/null differ diff --git a/docs/Glucosemeter Project Logboek.docx b/docs/Glucosemeter Project Logboek.docx deleted file mode 100644 index 66c4776..0000000 Binary files a/docs/Glucosemeter Project Logboek.docx and /dev/null differ diff --git a/src/GlucoseCheck.py b/src/GlucoseCheck.py index f985860..8f757f1 100644 --- a/src/GlucoseCheck.py +++ b/src/GlucoseCheck.py @@ -17,22 +17,20 @@ brokercreds = ["hass","Bruk#5"] # API JWT token, Account-Id and Patient_Id jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImM1ZGVhZGZiLTNlZDYtMTFlYS1hZjZmLTAyNDJhYzExMDAwYSIsImZpcnN0TmFtZSI6IkdlcnRqYW4iLCJsYXN0TmFtZSI6Iktvb2xlbiIsImNvdW50cnkiOiJOTCIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJzIjoibGx1LmFuZHJvaWQiLCJzaWQiOiIyZDM3NTJmNy01M2EwLTQ2N2ItOTAyNS02YmIzODBmZTYxZWEiLCJleHAiOjE3NzY1MDYwNTIsImlhdCI6MTc2MDk1NDA1MiwianRpIjoiNDYzYmRiZjQtNjJiNi00N2I4LWJiNzYtN2FmMmJjNGY2YjkzIn0.0pxP3zagyWaTF-r0F9mHOtSsbsMwz3lUvzEnQQmDNek" -#Account_ID = "dad20d62aeef891d94bda411af269900180cb7b84a0ce51d60b52463339935b1" Patient_ID = "c5deadfb-3ed6-11ea-af6f-0242ac11000a" # API endpoint for login -#url = f"https://api-eu.libreview.io/llu/connections/{Patient_ID}/graph" -url = f"https://libreview-proxy.onrender.com/eu/auth/continue/tou" +url = "https://api-eu.libreview.io/llu/connections/" digest = hashlib.sha256(Patient_ID.encode('utf-8')).digest() Account_ID = binascii.hexlify(digest).decode('utf-8') # Headers headers = { - "Accept": "application/json", # This nececcery - "product": "llu.android", # This nececcery - "version": "4.16", # Version older then 4.12.0 gives error. + "Accept": "application/json", # This is nessesary + "product": "llu.android", # This is nessesary + "version": "4.16", # Version older than 4.16 is not supported by the server anymore (after 8 Okt 2025) "Authorization": f"Bearer {jwt_token}", # JWT_token for login - "Account-Id" : Account_ID # Extra login credentials + "Account-Id" : Account_ID # Extra login credentials. Account_ID is the SHA256 digest of the Patient_ID (that we got in the first step where we got the jwt_token) } # limits_table[0] is after just compensating (no eating), and [1] is after eating @@ -55,7 +53,7 @@ limits_max_hours = 4 # nr of hours in the above lists last_bolus_time = time.time()-3600 last_bolus_type = 0 -GLUC_READOUT_PERIOD = 1 #5 # in minutes +GLUC_READOUT_PERIOD = 5 # in minutes GLUC_SLOPE_PERIOD = 30 # in minutes GLUC_BUFFER_LENGTH = round(GLUC_SLOPE_PERIOD/GLUC_READOUT_PERIOD) gluc_buffer = deque([6.0] * GLUC_BUFFER_LENGTH, maxlen=GLUC_BUFFER_LENGTH) # The gluc_buffer always contains only the last xx elements. Initialized on 6.0 @@ -64,15 +62,8 @@ gluc_buffer = deque([6.0] * GLUC_BUFFER_LENGTH, maxlen=GLUC_BUFFER_LENGTH) def glucose_value(data_glucose): #Inputs json string and unbinds glucose value # Gets glucose value - glucose_data = data_glucose.get("data", {}).get("connection", {}).get("glucoseMeasurement", {} ).get("Value") + glucose_data = data_glucose['data'][0]['glucoseMeasurement']['Value'] return glucose_data -def graph_value(data_graph): #Inputs json string and unbinds glucose graph and turns into dictionary - # Gets the whole graph - graph_data = data_graph.get("data", {}).get("graphData", []) - # Turns Date into a dict - graph_dict = {entry["Timestamp"]: entry["Value"] for entry in graph_data} - return graph_dict - # Main loop that runs code def main(url_main, headers_main): diff --git a/src/Glucose_http_jwt.py b/src/Glucose_http_jwt.py index ad058ec..46209e4 100644 --- a/src/Glucose_http_jwt.py +++ b/src/Glucose_http_jwt.py @@ -1,8 +1,7 @@ import requests # API endpoint for login -#url = "https://api-eu.libreview.io/llu/auth/login" # Replace with the actual API URL -url = "https://libreview-proxy.onrender.com/eu/llu/auth/login" # Replace with the actual API URL +url = "https://api-eu.libreview.io/llu/auth/login" # Login credentials payload = { @@ -30,6 +29,7 @@ if response.status_code == 200: if data.get("status") == 0 and "authTicket" in data.get("data", {}): jwt_token = data["data"]["authTicket"]["token"] print("Login successful! JWT Token:", jwt_token) + print(data); else: print("Status = ", data.get("status")) print("Login failed: Unexpected response format")