def set_current_target_temperature(): data = request.get_json() if not data or \ not data.get('temperature'): return (jsonify(success=False, error="'temperature' field is required"), 400) add_target_temperature(data['temperature']) return jsonify(success=True)
def update_nickname(): data = request.get_json() if not data or \ not data.get('nickname'): return (jsonify(success=False, error="'nickname' field is required"), 400) update_info_nickname(data['nickname']) return jsonify(success=True)
def general_info(): info = dict(get_info()) info['current_temperature'] = get_current_temperature() rec = get_latest_target_temperature() if rec: info['current_target_temperature'] = rec['temperature'] return jsonify(info)
def get_target_temperature_history(): entries = [dict(row) for row in get_all_target_temperatures()] return jsonify(entries)
def get_current_target_temperature(): rec = get_latest_target_temperature() if not rec: return jsonify(temperature=None) return jsonify(temperature=rec['temperature'])
def current_temperature(): return jsonify(temperature=get_current_temperature())