예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
def get_target_temperature_history():
    entries = [dict(row) for row in get_all_target_temperatures()]
    return jsonify(entries)
예제 #5
0
def get_current_target_temperature():
    rec = get_latest_target_temperature()
    if not rec:
        return jsonify(temperature=None)

    return jsonify(temperature=rec['temperature'])
예제 #6
0
def current_temperature():
    return jsonify(temperature=get_current_temperature())