Added Glucose check code
Ding toegevoegt zodat je kan aangeven hoelang geleden je hebt gespoten
This commit is contained in:
parent
02b4061c91
commit
606bd02967
2 changed files with 35 additions and 12 deletions
|
|
@ -126,16 +126,33 @@ def on_message(client, userdata, msg): #This runs everytime a mqtt message
|
||||||
global last_bolus_time
|
global last_bolus_time
|
||||||
global last_bolus_type
|
global last_bolus_type
|
||||||
args = msg.payload.decode()
|
args = msg.payload.decode()
|
||||||
|
args_list = args.split(" ")
|
||||||
if not args:
|
if not args:
|
||||||
#Empty string
|
#Empty string
|
||||||
|
print("koekwous")
|
||||||
return
|
return
|
||||||
elif args[0] == "c": #Sets compesation var
|
elif args_list[0][0] == "c": #Sets compesation var
|
||||||
last_bolus_type = 0
|
if len(args_list) > 1:
|
||||||
elif args[0] == "e": #Sets eating var
|
try:
|
||||||
last_bolus_type = 1
|
last_bolus_time = time.time() - 3600 * float(args_list[1])
|
||||||
last_bolus_time = time.time()
|
last_bolus_type = 0
|
||||||
|
except Exception as e:
|
||||||
|
Mqtt.publish(send_topic, f"Error: {e}")
|
||||||
|
else:
|
||||||
|
last_bolus_type = 0
|
||||||
|
last_bolus_time = time.time()
|
||||||
|
elif args_list[0][0] == "e": #Sets eating var
|
||||||
|
if len(args_list) > 1:
|
||||||
|
try:
|
||||||
|
last_bolus_time = time.time() - 3600 * float(args_list[1])
|
||||||
|
last_bolus_type = 1
|
||||||
|
except Exception as e:
|
||||||
|
Mqtt.publish(send_topic, f"Error: {e}")
|
||||||
|
else:
|
||||||
|
last_bolus_type = 1
|
||||||
|
last_bolus_time = time.time()
|
||||||
print("Bolussen")
|
print("Bolussen")
|
||||||
print(last_bolus_type)
|
print(last_bolus_time)
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Site: #Custom classes for my dictionaries
|
||||||
self.typeVar = typeVar
|
self.typeVar = typeVar
|
||||||
|
|
||||||
webServers = {"Google" : Site(url="https://google.com", typeVar="URL"), #List with all the servers urls and names and types
|
webServers = {"Google" : Site(url="https://google.com", typeVar="URL"), #List with all the servers urls and names and types
|
||||||
"GameServer" : Site(url="http://192.168.1.251", typeVar="URL"),
|
"GameServer" : Site(url="http://192.168.0.251", typeVar="URL"),
|
||||||
"SpiritBody" : Site(url="https://spiritbodyhealing.org", typeVar="URL"),
|
"SpiritBody" : Site(url="https://spiritbodyhealing.org", typeVar="URL"),
|
||||||
"HeresYourSign": Site(url="https://heresyoursign.nl", typeVar="URL"),
|
"HeresYourSign": Site(url="https://heresyoursign.nl", typeVar="URL"),
|
||||||
#"SMB_server": Site(url="192.168.1.250", typeVar="SMB"),
|
#"SMB_server": Site(url="192.168.1.250", typeVar="SMB"),
|
||||||
|
|
@ -153,9 +153,9 @@ def on_message(client, userdata, msg): #This runs everytime a mqtt message
|
||||||
if User[i].name.lower() == user_topic:
|
if User[i].name.lower() == user_topic:
|
||||||
print(f"right: {user_topic}: {i}")
|
print(f"right: {user_topic}: {i}")
|
||||||
if User[i].mute > 0: #Removes mute for user
|
if User[i].mute > 0: #Removes mute for user
|
||||||
User[keys[0]].mute = 0
|
#User[keys[0]].mute = 0
|
||||||
User[keys[1]].mute = 0
|
#User[keys[1]].mute = 0
|
||||||
#User[i].mute = 0
|
User[i].mute = 0
|
||||||
else:
|
else:
|
||||||
User[i].mute = mute_time//interval_offline_message #This mutes for a time
|
User[i].mute = mute_time//interval_offline_message #This mutes for a time
|
||||||
elif args[0] == "s":
|
elif args[0] == "s":
|
||||||
|
|
@ -176,8 +176,14 @@ def main(): #This is the main loop
|
||||||
while True:
|
while True:
|
||||||
checkWebServer(webServers) #Update list of websites status
|
checkWebServer(webServers) #Update list of websites status
|
||||||
messageStatus = statusCheck(False) #False is only on state change
|
messageStatus = statusCheck(False) #False is only on state change
|
||||||
if User[keys[0]].mute == 0 | User[keys[1]].mute == 0: # If anyone has muted it wont send message
|
keys = list(User.keys())
|
||||||
Mqtt.publish(send_topic + "broadcast", messageStatus)
|
for i in keys:
|
||||||
|
if User[i].mute == 0:
|
||||||
|
print(User[i].name.lower())
|
||||||
|
Mqtt.publish(send_topic + User[i].name.lower(), messageStatus)
|
||||||
|
sleep(1)
|
||||||
|
#if User[keys[0]].mute == 0 | User[keys[1]].mute == 0: # If anyone has muted it wont send message
|
||||||
|
# Mqtt.publish(send_topic + "broadcast", messageStatus)
|
||||||
sleep(30)
|
sleep(30)
|
||||||
if User[keys[0]].mute > 0: #Counts down mute for User 0
|
if User[keys[0]].mute > 0: #Counts down mute for User 0
|
||||||
User[keys[0]].mute = User[keys[0]].mute - 1
|
User[keys[0]].mute = User[keys[0]].mute - 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue