Add debug.
This commit is contained in:
parent
49dc3fa220
commit
0117512928
@ -273,25 +273,22 @@ def thermostat_loop():
|
|||||||
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)
|
||||||
|
logging.debug("Update mode in DB")
|
||||||
try:
|
try:
|
||||||
logging.debug("Insert mode in DB")
|
cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
||||||
db.session.add(data)
|
logging.debug("Remove current mode: "+str(cur_mode.value))
|
||||||
db.session.commit()
|
db.session.delete(cur_mode)
|
||||||
except sqlalchemy.exc.IntegrityError as e:
|
|
||||||
try:
|
|
||||||
logging.debug("Row already exists in DB.")
|
|
||||||
db.session.rollback()
|
|
||||||
logging.debug("Update mode in DB")
|
|
||||||
cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
|
||||||
logging.debug("Current mode: "+str(cur_mode.value))
|
|
||||||
cur_mode = data
|
|
||||||
db.session.commit()
|
|
||||||
except Exception as e:
|
|
||||||
db.session.rollback()
|
|
||||||
logging.error(e)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(e)
|
logging.debug(e)
|
||||||
|
try:
|
||||||
|
logging.debug("Insert mode in DB")
|
||||||
|
db.session.add(data)
|
||||||
|
db.session.commit()
|
||||||
|
except Exception as e:
|
||||||
|
db.session.rollback()
|
||||||
|
db.session.commit()
|
||||||
|
logging.error(e)
|
||||||
|
|
||||||
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
||||||
#dbconn.commit()
|
#dbconn.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user