try to fix script check

This commit is contained in:
GJ Koolen 2025-10-20 12:00:23 +02:00
parent fa75a6b218
commit d18f70961d
2 changed files with 19 additions and 14 deletions

View file

@ -1,6 +1,8 @@
import requests
import time
import paho.mqtt.client as mqtt
import hashlib
import binascii
from datetime import datetime
from collections import deque
@ -14,18 +16,21 @@ brokercreds = ["hass","Bruk#5"]
##### Variables #####
# API JWT token, Account-Id and Patient_Id
jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImM1ZGVhZGZiLTNlZDYtMTFlYS1hZjZmLTAyNDJhYzExMDAwYSIsImZpcnN0TmFtZSI6IkdlcnRqYW4iLCJsYXN0TmFtZSI6Iktvb2xlbiIsImNvdW50cnkiOiJOTCIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJlbWFpbCI6Imdqa29vbGVuQGdtYWlsLmNvbSIsInMiOiJsbHUuYW5kcm9pZCIsInNpZCI6IjkzYTZmMmU2LWRjNDQtNDA0Mi04YjBiLTcxMGQ3MzAyMzMyNSIsInRhc2tUeXBlIjoidG91IiwiZXhwIjoxNzYwMTkzMDM2LCJpYXQiOjE3NjAxODk0MzYsImp0aSI6ImU0NTRlYzljLTE2ZTMtNDQwMy05YjYyLTc0NjAxZTkzNDFjOSJ9.hiyrVjE2kWvBr2DjtPojdTDtkqNrPI57HubXYl4Kko0"
Account_ID = "dad20d62aeef891d94bda411af269900180cb7b84a0ce51d60b52463339935b1"
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"
digest = hashlib.sha256(Patient_ID.encode('utf-8')).digest()
Account_ID = binascii.hexlify(digest).decode('utf-8')
# Headers
headers = {
"content-type": "application/json", # This nececcery
"Accept": "application/json", # This nececcery
"product": "llu.android", # This nececcery
"version": "4.13.0", # Version older then 4.12.0 gives error.
"version": "4.16", # Version older then 4.12.0 gives error.
"Authorization": f"Bearer {jwt_token}", # JWT_token for login
"Account-Id" : Account_ID # Extra login credentials
}
@ -50,7 +55,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 = 5 # in minutes
GLUC_READOUT_PERIOD = 1 #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
@ -106,7 +111,6 @@ def main(url_main, headers_main):
print("Hey joh check je glucosepeil !")
Mqtt.publish(send_topic, f"Hey joh check peil ! (lastbolus -{round(hours_since_last_bolus, 1)})")
else: # Request has failed
print(f"❌ Error: Could not connect to server: {response.status_code}")
except requests.exceptions.JSONDecodeError:

View file

@ -1,7 +1,8 @@
import requests
# API endpoint for login
url = "https://api-eu.libreview.io/llu/auth/login" # Replace with the actual API URL
#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
# Login credentials
payload = {
@ -14,9 +15,9 @@ headers = {
'accept-encoding': 'gzip',
'cache-control': 'no-cache',
'connection': 'Keep-Alive',
'content-type': 'application/json',
'Accept': 'application/json',
'product': 'llu.android',
'version': '4.7'
'version': '4.16'
}
# Send the POST request