Continue Flask migration.
This commit is contained in:
parent
2c747d75e4
commit
a4eefa18b7
@ -179,7 +179,7 @@ class Set_mode(db.Model):
|
|||||||
|
|
||||||
Set_mode_resource_fields = {
|
Set_mode_resource_fields = {
|
||||||
'name': fields.String(description='mode type'),
|
'name': fields.String(description='mode type'),
|
||||||
'value': fields.String(required=True, description='value'),
|
'value': fields.String(required=True, description='value', enum=targets+modes),
|
||||||
'time': fields.DateTime(dt_format='iso8601'),
|
'time': fields.DateTime(dt_format='iso8601'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,24 +195,27 @@ class Set_mode_thermostat(Resource):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
return "K0", 400
|
return "K0", 400
|
||||||
try:
|
new_forced_mode = data.value
|
||||||
db.session.add(data)
|
return "OK", 201
|
||||||
db.session.commit()
|
|
||||||
return "OK", 201
|
# try:
|
||||||
except sqlalchemy.exc.IntegrityError as e:
|
# db.session.add(data)
|
||||||
try:
|
# db.session.commit()
|
||||||
db.session.rollback()
|
# return "OK", 201
|
||||||
cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
# except sqlalchemy.exc.IntegrityError as e:
|
||||||
cur_mode = data
|
# try:
|
||||||
db.session.commit()
|
# db.session.rollback()
|
||||||
except Exception as e:
|
# cur_mode = db.session.execute(db.select(Set_mode).filter_by(name="mode")).scalar_one()
|
||||||
db.session.rollback()
|
# cur_mode = data
|
||||||
logging.error(e)
|
# db.session.commit()
|
||||||
return "K0", 400
|
# except Exception as e:
|
||||||
except Exception as e:
|
# db.session.rollback()
|
||||||
db.session.rollback()
|
# logging.error(e)
|
||||||
logging.error(e)
|
# return "K0", 400
|
||||||
return "K0", 400
|
# except Exception as e:
|
||||||
|
# db.session.rollback()
|
||||||
|
# logging.error(e)
|
||||||
|
# return "K0", 400
|
||||||
|
|
||||||
@ns_thermostat.route('/status')
|
@ns_thermostat.route('/status')
|
||||||
class Status_thermostat(Resource):
|
class Status_thermostat(Resource):
|
||||||
@ -238,14 +241,15 @@ migrate = Migrate(app, db, compare_type=True)
|
|||||||
target_name = default_target
|
target_name = default_target
|
||||||
forced_mode = None
|
forced_mode = None
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
new_forced_mode = None
|
||||||
|
|
||||||
def thermostat_loop():
|
def thermostat_loop():
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
last_control_time = None
|
last_control_time = None
|
||||||
new_forced_mode = None
|
|
||||||
first_loop = True
|
first_loop = True
|
||||||
global target_name
|
global target_name
|
||||||
global forced_mode
|
global forced_mode
|
||||||
|
global new_forced_mode
|
||||||
global current_time
|
global current_time
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user