Add debug.

This commit is contained in:
yohan 2024-06-05 07:20:35 +02:00
parent d238c86099
commit 1ef4ada723

View File

@ -274,11 +274,14 @@ def thermostat_loop():
with app.app_context():
data = Set_mode(value=new_forced_mode)
try:
logging.debug("Insert mode in DB")
db.session.add(data)
db.session.commit()
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()
cur_mode = data
db.session.commit()