示例#1
0
def open():
    if tools.get_config('thermostat_status') == 'closed':
        motor_controller.turn(1, 0.35, 1)
        tools.write_config('thermostat_status', 'open')
        return 'Opend thermostat'
    else:
        return 'thermostat already open'
示例#2
0
def close():
    if tools.get_config('thermostat_status') == 'open':
        motor_controller.turn(-1, 0.35, 1)
        tools.write_config('thermostat_status', 'closed')
        return 'closed thermostat'
    else:
        return 'thermostat already closed'
示例#3
0
def set_times():
    if tools.get_config("box_status") == "open":
        tools.write_config("open_time", request.args.get('open'))
        tools.write_config("close_time", request.args.get('close'))
        return "Open/closing times are set!"
    else:
        return "The box is closed! You can not change these settings now"
示例#4
0
def set_to_next_friday():
    next_friday = tools.get_next_friday()
    tools.write_config("close_time",
                       datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
    tools.write_config("open_time", next_friday.strftime("%Y-%m-%d %H:%M"))
    print(next_friday.strftime("%Y-%m-%d %H:%M"))
    box.close_box()
    return 'date set to next friday!'
示例#5
0
文件: box.py 项目: cedric5/LockBox
def open_box():
    print("opening box: unlocking")
    pi = pigpio.pi()
    pi.set_servo_pulsewidth(17, 2000)
    sleep(0.2)
    pi.set_servo_pulsewidth(17, 0)
    print("opening box: opening lid")
    pi.set_servo_pulsewidth(23, 1725)
    sleep(0.1)
    tools.write_config("open_time", "")
    tools.write_config("box_status", "open")
    print('Box has been opened!')
示例#6
0
文件: timer.py 项目: cedric5/LockBox
def check_times():
    if tools.config_is_set("open_time") or tools.config_is_set("close_time"):
        tools.write_config('mode', 'automatic')
    else:
        tools.write_config('mode', 'manual')
    box_status = tools.get_config("box_status")
    times = tools.time_left(box_status)
    days = times[0]
    hours = times[1]
    minutes = times[2]
    seconds = times[3]
    time_left_total = days + hours + minutes + seconds
    if time_left_total < 1 or days < 0:
        move_lid(box_status)
示例#7
0
文件: box.py 项目: cedric5/LockBox
def close_box():
    pi = pigpio.pi()
    print("closing box: closing lid")
    pi.set_servo_pulsewidth(23, 0)
    pulse = 1725  # open position of lid
    while pulse > 1000:  # 1100 close position of lid
        pulse -= 25
        pi.set_servo_pulsewidth(23, pulse)
        sleep(0.03)
    pi.set_servo_pulsewidth(23, 0)
    print("closing box: locking")
    sleep(0.15)
    pi.set_servo_pulsewidth(17, 2250)
    sleep(1)
    pi.set_servo_pulsewidth(17, 0)
    tools.write_config("close_time", "")
    tools.write_config("box_status", "closed")
    print('Box has been closed!')
示例#8
0
def check_temps():
    thermostat_status = tools.get_config('thermostat_status')
    goal_temp = tools.get_config('goal_temp')
    actual_temp = temp_controller.get_temp_float()

    print(f'goal_temp: {goal_temp}')
    print(f'actual_temp: {actual_temp}')

    if actual_temp >= goal_temp:
        if thermostat_status == 'open':
            print('closing')
            motor_controller.turn(-1, 0.35, 1)
            tools.write_config('thermostat_status', 'closed')
    else:
        if thermostat_status == 'closed':
            print('opening')
            motor_controller.turn(1, 0.35, 1)
            tools.write_config('thermostat_status', 'open')
示例#9
0
def temp_min():
    old_temp = tools.get_config('goal_temp')
    tools.write_config('goal_temp', old_temp - 0.5)
    return f'new goal temp: {old_temp - 0.5}'
示例#10
0
def set_wifi():
    wifi_client.connect(request.args.get('ssid'), request.args.get('wpa2'))
    tools.write_config("wifi_ssid", request.args.get('ssid'))
    tools.write_config("wpa2", request.args.get('wpa2'))
    return "Set wifi settings saved!"