New Proxmox IP addres
Aangepaste IP adres (voor Proxmox) en renewed jwt token,. Dit is de huidige werkende versie op de RPi.
This commit is contained in:
parent
6b3b1217ae
commit
281fa33436
2 changed files with 10 additions and 8 deletions
Binary file not shown.
|
|
@ -5,8 +5,8 @@ from datetime import datetime
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
##### Mqtt vars #####
|
##### Mqtt vars #####
|
||||||
broker_address = "192.168.1.250"
|
broker_address = "192.168.1.160"
|
||||||
broker_port = 1883
|
broker_port = 1883
|
||||||
recieve_topic = "telegrambot/in/glucose/gj"
|
recieve_topic = "telegrambot/in/glucose/gj"
|
||||||
send_topic = "telegrambot/out/gj"
|
send_topic = "telegrambot/out/gj"
|
||||||
brokercreds = ["hass","Bruk#5"]
|
brokercreds = ["hass","Bruk#5"]
|
||||||
|
|
@ -14,11 +14,12 @@ brokercreds = ["hass","Bruk#5"]
|
||||||
##### Variables #####
|
##### Variables #####
|
||||||
|
|
||||||
# API JWT token, Account-Id and Patient_Id
|
# API JWT token, Account-Id and Patient_Id
|
||||||
jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImM1ZGVhZGZiLTNlZDYtMTFlYS1hZjZmLTAyNDJhYzExMDAwYSIsImZpcnN0TmFtZSI6IkdlcnRqYW4iLCJsYXN0TmFtZSI6Iktvb2xlbiIsImNvdW50cnkiOiJOTCIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJzIjoibGx1LmFuZHJvaWQiLCJzaWQiOiIxNjE5NmZkMy1mMmEzLTQ0MWMtOGEwZi03Y2Y2YjAyODQwZjYiLCJleHAiOjE3Njk1ODY1NjgsImlhdCI6MTc1NDAzNDU2OCwianRpIjoiNWQwZjI4NTctZmI2My00ZDlhLWE4MDAtZjVhNWNhMjg4MzZiIn0.4GupiVfdhIlavbMTTNQcy8UMeAvwnsSzdmfvQMVcoV8"
|
jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImM1ZGVhZGZiLTNlZDYtMTFlYS1hZjZmLTAyNDJhYzExMDAwYSIsImZpcnN0TmFtZSI6IkdlcnRqYW4iLCJsYXN0TmFtZSI6Iktvb2xlbiIsImNvdW50cnkiOiJOTCIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJlbWFpbCI6Imdqa29vbGVuQGdtYWlsLmNvbSIsInMiOiJsbHUuYW5kcm9pZCIsInNpZCI6IjkzYTZmMmU2LWRjNDQtNDA0Mi04YjBiLTcxMGQ3MzAyMzMyNSIsInRhc2tUeXBlIjoidG91IiwiZXhwIjoxNzYwMTkzMDM2LCJpYXQiOjE3NjAxODk0MzYsImp0aSI6ImU0NTRlYzljLTE2ZTMtNDQwMy05YjYyLTc0NjAxZTkzNDFjOSJ9.hiyrVjE2kWvBr2DjtPojdTDtkqNrPI57HubXYl4Kko0"
|
||||||
Account_ID = "dad20d62aeef891d94bda411af269900180cb7b84a0ce51d60b52463339935b1"
|
Account_ID = "dad20d62aeef891d94bda411af269900180cb7b84a0ce51d60b52463339935b1"
|
||||||
Patient_ID = "c5deadfb-3ed6-11ea-af6f-0242ac11000a"
|
Patient_ID = "c5deadfb-3ed6-11ea-af6f-0242ac11000a"
|
||||||
# API endpoint for login
|
# API endpoint for login
|
||||||
url = f"https://api-eu.libreview.io/llu/connections/{Patient_ID}/graph"
|
#url = f"https://api-eu.libreview.io/llu/connections/{Patient_ID}/graph"
|
||||||
|
url = f"https://libreview-proxy.onrender.com/eu/auth/continue/tou"
|
||||||
|
|
||||||
# Headers
|
# Headers
|
||||||
headers = {
|
headers = {
|
||||||
|
|
@ -75,10 +76,11 @@ def main(url_main, headers_main):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Send the Get request
|
# Send the Get request
|
||||||
|
print(f"connecting to Libreview server, address: {url_main} with headers {headers_main}")
|
||||||
response = requests.get(url_main, headers=headers_main) # json=payload
|
response = requests.get(url_main, headers=headers_main) # json=payload
|
||||||
if response.status_code == 200: # If request has succeeded
|
if response.status_code == 200: # If request has succeeded
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
gluc_value = glucose_value(data)
|
gluc_value = glucose_value(data)
|
||||||
print(f"current level: {gluc_value}")
|
print(f"current level: {gluc_value}")
|
||||||
|
|
||||||
|
|
@ -86,7 +88,7 @@ def main(url_main, headers_main):
|
||||||
gluc_buffer.append(gluc_value)
|
gluc_buffer.append(gluc_value)
|
||||||
old_value = list(gluc_buffer)[0]
|
old_value = list(gluc_buffer)[0]
|
||||||
print(f"old level: {old_value}")
|
print(f"old level: {old_value}")
|
||||||
gluc_slope = (gluc_value-old_value)* 60 / 30 # slope is gluc_level per hour (normalized)
|
gluc_slope = (gluc_value-old_value)* 60 / 30 # slope is gluc_level per hour (normalized)
|
||||||
print(f"slope: {gluc_slope}")
|
print(f"slope: {gluc_slope}")
|
||||||
|
|
||||||
print(f"time.time: {time.time()}")
|
print(f"time.time: {time.time()}")
|
||||||
|
|
@ -103,7 +105,7 @@ def main(url_main, headers_main):
|
||||||
(gluc_slope > limits_table[last_bolus_type][int(hours_since_last_bolus)][1])):
|
(gluc_slope > limits_table[last_bolus_type][int(hours_since_last_bolus)][1])):
|
||||||
print("Hey joh check je glucosepeil !")
|
print("Hey joh check je glucosepeil !")
|
||||||
Mqtt.publish(send_topic, f"Hey joh check peil ! (lastbolus -{round(hours_since_last_bolus, 1)})")
|
Mqtt.publish(send_topic, f"Hey joh check peil ! (lastbolus -{round(hours_since_last_bolus, 1)})")
|
||||||
|
|
||||||
|
|
||||||
else: # Request has failed
|
else: # Request has failed
|
||||||
print(f"❌ Error: Could not connect to server: {response.status_code}")
|
print(f"❌ Error: Could not connect to server: {response.status_code}")
|
||||||
|
|
@ -157,7 +159,7 @@ def on_message(client, userdata, msg): #This runs everytime a mqtt message
|
||||||
|
|
||||||
Mqtt = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) #Creates a mqqt object
|
Mqtt = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) #Creates a mqqt object
|
||||||
Mqtt.on_connect = on_connect #Create callback on connect
|
Mqtt.on_connect = on_connect #Create callback on connect
|
||||||
Mqtt.on_message = on_message #Create callback on message
|
Mqtt.on_message = on_message #Create callback on message
|
||||||
|
|
||||||
Mqtt.username_pw_set(brokercreds[0], password=brokercreds[1]) #Set User and Password
|
Mqtt.username_pw_set(brokercreds[0], password=brokercreds[1]) #Set User and Password
|
||||||
Mqtt.connect(broker_address, broker_port, 60) #Set Connection settings
|
Mqtt.connect(broker_address, broker_port, 60) #Set Connection settings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue