Пример #1
0
def start_pid(value):
    auto = control.latest('log.auto_mode')
    if not auto:
        # Start PID by changing setpoint to current temperature
        setpoint = control.latest('log.temperature')
        control.publish('set.setpoint', setpoint)
    return '{0} °C/minute'.format(value)
Пример #2
0
def update_pid(value):
    auto = control.latest('log.auto_mode')
    if auto:
        # Already running PID, so increment setpoint by given degC/minute
        setpoint = control.latest(
            'log.setpoint') + value * UPDATE_INTERVAL / 60
        control.publish('set.setpoint', setpoint)
    return '{0} °C/minute'.format(value)
Пример #3
0
def stopwatch():
    # Get last stopwatch reset
    reset_time = control.latest('log.stopwatch')
    elapsed = time.time() - reset_time if reset_time else 0
    # Return stopwatch value
    return 'Stopwatch: {minutes:02d}:{seconds:02d}'.format(
        minutes=int(elapsed / 60), seconds=int(elapsed % 60))
Пример #4
0
def badge_auto(invert=False):
    # Use this to change icon colours when in manual/PID mode
    auto = control.latest('log.auto_mode')
    class_name = 'badge badge-pill badge-'
    if auto:
        return class_name + ('secondary' if invert else 'success')
    else:
        return class_name + ('success' if invert else 'secondary')
Пример #5
0
def table():
    data = control.latest(
        ['log.temperature', 'log.temperature_roc', 'log.heat', 'log.setpoint'])
    return [
        html.Tr([
            html.Td(key.replace('log.', '')),
            html.Td('{0:.1f}'.format(value))
        ]) for key, value in data.items()
    ]