예제 #1
0
파일: routes.py 프로젝트: simonsan/GardenPi
def gardenpi():
    # Get Power Readings
    log.debug('gardenpi() called')
    if system_info.power_monitoring:
        current_power_keys = [
            'total_current_power_utilization', 'total_current_power_import',
            'total_current_solar_production'
        ]
        power_data = {}
        for key in current_power_keys:
            power_data[key] = read_mysql_database("power_solar", key)
    else:
        power_data = {
            'total_current_power_utilization': 0,
            'total_current_power_import': 0,
            'total_current_solar_production': 0
        }
    any_zones_running = neptune.any_zones_running('water')
    any_power_zones_running = neptune.any_zones_running('power')
    current_water_source = (neptune.get_water_source()['source_to_use'])
    return render_template('gardenpi_index.html',
                           any_zones_running=any_zones_running,
                           current_water_source=current_water_source,
                           any_power_zones_running=any_power_zones_running,
                           **power_data)
예제 #2
0
def change_water_source():
    """Function to actually change our water source if we run out of water."""
    global checked
    if not checked:
        checked = True
        if (get_water_source()['job_water_source']) == 'fish_water':
            print('switching source')
            switch_from_fish_source()
예제 #3
0
파일: routes.py 프로젝트: simonsan/GardenPi
def zone(id):
    zone = f'zone{id}'
    log.debug(f'zone() called with zone: {zone}')
    any_zones_running = neptune.any_zones_running('water')
    is_zone_enabled = neptune.zone_enabled(zone)
    is_zone_running = neptune.is_this_zone_running(zone)
    is_zone_running_manually = neptune.is_this_zone_running_manually(zone)
    job1_enabled = (neptune.get_schedule_by_zone_job(zone, '1')[0][3])
    job2_enabled = (neptune.get_schedule_by_zone_job(zone, '2')[0][3])
    job1_running = (neptune.get_schedule_by_zone_job(zone, '1')[0][7])
    job2_running = (neptune.get_schedule_by_zone_job(zone, '2')[0][7])
    total_zone_water_usage = water_usage(zone, 'read_total_gallons_used', 0)
    running_current_total_gallons = water_usage(zone,
                                                'read_gallons_current_run', 0)
    current_gpm = neptune.get_current_gpm()
    current_water_source = (neptune.get_water_source()['source_to_use'])
    any_notification_source_available = neptune.notifications(
        'systemwide', 'enabled', 'check')
    notifications_enabled = neptune.notifications(zone, 'notifications',
                                                  'enabled')
    systemwide_notifications_enabled = neptune.notifications(
        'systemwide', 'enabled', 'enabled')
    sms_enabled = neptune.notifications(zone, 'sms', 'enabled')
    pb_enabled = neptune.notifications(zone, 'pb', 'enabled')
    email_enabled = neptune.notifications(zone, 'email', 'enabled')

    if job1_running:
        job_id = (neptune.get_schedule_by_zone_job(zone, '1')[0][0])
    elif job2_running:
        job_id = (neptune.get_schedule_by_zone_job(zone, '2')[0][0])
    else:
        job_id = ''

    return render_template(
        'zone.html',
        zone_enabled=is_zone_enabled,
        is_zone_running=is_zone_running,
        is_zone_running_manually=is_zone_running_manually,
        any_zones_running=any_zones_running,
        job1_enabled=job1_enabled,
        job2_enabled=job2_enabled,
        job1_running=job1_running,
        job2_running=job2_running,
        total_zone_water_usage=total_zone_water_usage,
        running_current_total_gallons=running_current_total_gallons,
        current_gpm=current_gpm,
        current_water_source=current_water_source,
        notifications_enabled=notifications_enabled,
        any_notification_source_available=any_notification_source_available,
        systemwide_notifications_enabled=systemwide_notifications_enabled,
        sms_enabled=sms_enabled,
        email_enabled=email_enabled,
        pb_enabled=pb_enabled,
        job_id=job_id,
        id=id)
예제 #4
0
파일: routes.py 프로젝트: imfht/flaskapps
def water_source():
    log.debug('water_source() called')
    water_source = neptune.get_water_source()
    is_fresh_zone_running = neptune.is_this_zone_running('fresh_water')
    is_fish_zone_running = neptune.is_this_zone_running('fish_water')
    any_zones_running = neptune.any_zones_running('water')

    return render_template('water_source.html', any_zones_running = any_zones_running,
                           is_fresh_zone_running = is_fresh_zone_running,
                           is_fish_zone_running = is_fish_zone_running,
                           **water_source)
예제 #5
0
def run_check():
    """Function that watches our NC liquid level sensors and makes updates based on them."""
    global checked
    if not checked:
        if not mcp3.get_pin(nutrient_tank).value:
            toggle_fish_available(False)
            change_water_source()
    else:
        if mcp3.get_pin(nutrient_tank).value:
            checked = False
            if not (get_water_source()['fish_available']):
                toggle_fish_available(True)
    threading.Timer(.5, run_check).start()