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_type
|
||||
args = msg.payload.decode()
|
||||
args_list = args.split(" ")
|
||||
if not args:
|
||||
#Empty string
|
||||
print("koekwous")
|
||||
return
|
||||
elif args[0] == "c": #Sets compesation var
|
||||
last_bolus_type = 0
|
||||
elif args[0] == "e": #Sets eating var
|
||||
last_bolus_type = 1
|
||||
last_bolus_time = time.time()
|
||||
elif args_list[0][0] == "c": #Sets compesation var
|
||||
if len(args_list) > 1:
|
||||
try:
|
||||
last_bolus_time = time.time() - 3600 * float(args_list[1])
|
||||
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(last_bolus_type)
|
||||
print(last_bolus_time)
|
||||
|
||||
Mqtt = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) #Creates a mqqt object
|
||||
Mqtt.on_connect = on_connect #Create callback on connect
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Site: #Custom classes for my dictionaries
|
|||
self.typeVar = typeVar
|
||||
|
||||
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"),
|
||||
"HeresYourSign": Site(url="https://heresyoursign.nl", typeVar="URL"),
|
||||
#"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:
|
||||
print(f"right: {user_topic}: {i}")
|
||||
if User[i].mute > 0: #Removes mute for user
|
||||
User[keys[0]].mute = 0
|
||||
User[keys[1]].mute = 0
|
||||
#User[i].mute = 0
|
||||
#User[keys[0]].mute = 0
|
||||
#User[keys[1]].mute = 0
|
||||
User[i].mute = 0
|
||||
else:
|
||||
User[i].mute = mute_time//interval_offline_message #This mutes for a time
|
||||
elif args[0] == "s":
|
||||
|
|
@ -176,8 +176,14 @@ def main(): #This is the main loop
|
|||
while True:
|
||||
checkWebServer(webServers) #Update list of websites status
|
||||
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
|
||||
Mqtt.publish(send_topic + "broadcast", messageStatus)
|
||||
keys = list(User.keys())
|
||||
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)
|
||||
if User[keys[0]].mute > 0: #Counts down mute for User 0
|
||||
User[keys[0]].mute = User[keys[0]].mute - 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue