Continue Flask migration.
This commit is contained in:
parent
25fad3a6bf
commit
90d8f45b77
@ -98,6 +98,11 @@ def status_as_text():
|
||||
+'forced_mode: '+str(forced_mode)+'\n'\
|
||||
+'\n'.join(['Target temperature for '+room+': '+str(rooms_settings[room][target_name])+'\n'+'Current temperature for '+room+': '+str(get_metric(rooms_settings[room]["metric"], current_time, relay_control_interval)) for room in enabled_rooms()])
|
||||
|
||||
def status_as_dict():
|
||||
return {"target": target_name,\
|
||||
"forced_mode": str(forced_mode),\
|
||||
"enabled_rooms": {room: {'Target temperature': str(rooms_settings[room][target_name]), 'Current temperature': str(get_metric(rooms_settings[room]["metric"], current_time, relay_control_interval))} for room in enabled_rooms()}}
|
||||
|
||||
def relay_state(relay):
|
||||
try:
|
||||
returned_output = subprocess.check_output(["./relay.py", relay, "status"])
|
||||
@ -195,7 +200,7 @@ class Set_mode_thermostat(Resource):
|
||||
class Status_thermostat(Resource):
|
||||
@auth_required
|
||||
def get(self):
|
||||
result = dict(datas=status_as_text())
|
||||
result = status_as_dict()
|
||||
logging.debug(result)
|
||||
return result
|
||||
|
||||
@ -237,8 +242,8 @@ def thermostat_loop():
|
||||
data = Set_mode({"value": new_forced_mode})
|
||||
db.session.add(data)
|
||||
db.session.commit()
|
||||
# #cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
||||
# #dbconn.commit()
|
||||
#cursor.execute("INSERT OR REPLACE INTO set_mode (value) VALUES ('"+new_forced_mode+"')")
|
||||
#dbconn.commit()
|
||||
logging.info("Switch to "+new_forced_mode)
|
||||
target_name = new_forced_mode
|
||||
new_forced_mode = None
|
||||
|
Loading…
Reference in New Issue
Block a user