diff --git a/thermostat.py b/thermostat.py index 13a3397..1173881 100644 --- a/thermostat.py +++ b/thermostat.py @@ -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()