Continue Flask migration.

This commit is contained in:
yohan 2024-06-03 01:01:09 +02:00
parent 4a87b1b1e7
commit 031940a625

View File

@ -199,13 +199,13 @@ class Set_mode_thermostat(Resource):
@auth_required @auth_required
@api.expect(Set_mode_model, validate=True) @api.expect(Set_mode_model, validate=True)
def post(self): def post(self):
global new_forced_mode
try: try:
data = Set_mode(**request.json) data = Set_mode(**request.json)
except Exception as e: except Exception as e:
logging.error(e) logging.error(e)
return "K0", 400 return "K0", 400
new_forced_mode = data.value new_forced_mode = data.value
xprint(data)
xprint(new_forced_mode) xprint(new_forced_mode)
return "OK", 201 return "OK", 201
@ -270,6 +270,7 @@ def thermostat_loop():
# dbconn.close() # dbconn.close()
# break # break
xprint(new_forced_mode)
if new_forced_mode is not None: if new_forced_mode is not None:
with app.app_context(): with app.app_context():
data = Set_mode({"value": new_forced_mode}) data = Set_mode({"value": new_forced_mode})