示例#1
0
def environmentals():
    log.debug('environmentals() called')
    environmental_keys = [
        'pi_cpu_temp', 'enclosure_temp', 'enclosure_humidity',
        'enclosure_baro', 'shed_temp', 'shed_humidity', 'outdoor_temperature'
    ]
    environmental_data = {}
    for key in environmental_keys:
        environmental_data[key] = environmentals_data('readone', key, 0)

    worm_farm_temp = onewire_temp_probes('get_current_temp', 'worm_farm', 0)
    any_notification_source_available = neptune.notifications(
        'systemwide', 'enabled', 'check')
    systemwide_notifications_enabled = neptune.notifications(
        'systemwide', 'enabled', 'enabled')
    system_sms, system_pb, system_email = neptune.notifications(
        'systemwide', 0, 'check')

    return render_template(
        'environmentals.html',
        worm_farm_temp=worm_farm_temp,
        any_notification_source_available=any_notification_source_available,
        systemwide_notifications_enabled=systemwide_notifications_enabled,
        system_sms=system_sms,
        system_pb=system_pb,
        system_email=system_email,
        **environmental_data)
示例#2
0
文件: routes.py 项目: imfht/flaskapps
def environmental_notifications():
    log.debug('environmental_notifications() called')
    system_sms, system_pb, system_email = neptune.notifications('systemwide', 0, 'check')
    worm_farm_max_temp_sms = neptune.notifications('worm_farm_max_temp', 'sms', 'enabled')
    worm_farm_max_temp_pb = neptune.notifications('worm_farm_max_temp', 'pb', 'enabled')
    worm_farm_max_temp_email = neptune.notifications('worm_farm_max_temp', 'email', 'enabled')
    enclosure_max_temp_sms = neptune.notifications('enclosure_max_temp', 'sms', 'enabled')
    enclosure_max_temp_pb = neptune.notifications('enclosure_max_temp', 'pb', 'enabled')
    enclosure_max_temp_email = neptune.notifications('enclosure_max_temp', 'email', 'enabled')
    pi_max_cpu_temp_sms = neptune.notifications('pi_max_cpu_temp', 'sms', 'enabled')
    pi_max_cpu_temp_pb = neptune.notifications('pi_max_cpu_temp', 'pb', 'enabled')
    pi_max_cpu_temp_email = neptune.notifications('pi_max_cpu_temp', 'email', 'enabled')

    form = SetTempAlertLimitForm()
    form.worm_farm_max_temp.data = str(neptune.get_alert_limit('worm_farm_max_temp'))
    form.pi_max_cpu_temp.data = str(neptune.get_alert_limit('pi_max_cpu_temp'))
    form.enclosure_max_temp.data = str(neptune.get_alert_limit('enclosure_max_temp'))

    if form.validate_on_submit():
        neptune.update_alert_limit('worm_farm_max_temp', request.form['worm_farm_max_temp'])
        neptune.update_alert_limit('pi_max_cpu_temp', request.form['pi_max_cpu_temp'])
        neptune.update_alert_limit('enclosure_max_temp', request.form['enclosure_max_temp'])
        flash("Alert Limits Updated", "success")
        return redirect(url_for('environmental_notifications'))
    else:
        print("Validation Failed")
        print(form.errors)

    return render_template('environmental_notifications.html',
                           system_sms = system_sms, system_pb = system_pb, system_email=system_email,
                           worm_farm_max_temp_sms = worm_farm_max_temp_sms, worm_farm_max_temp_pb = worm_farm_max_temp_pb,
                           worm_farm_max_temp_email = worm_farm_max_temp_email, enclosure_max_temp_sms = enclosure_max_temp_sms,
                           enclosure_max_temp_pb = enclosure_max_temp_pb, enclosure_max_temp_email = enclosure_max_temp_email,
                           pi_max_cpu_temp_sms = pi_max_cpu_temp_sms, pi_max_cpu_temp_pb = pi_max_cpu_temp_pb,
                           pi_max_cpu_temp_email = pi_max_cpu_temp_email, form = form)
示例#3
0
def tools():
    log.debug('tools() called')
    any_notification_source_available = neptune.notifications(
        'systemwide', 'enabled', 'check')
    systemwide_notifications_enabled = neptune.notifications(
        'systemwide', 'enabled', 'enabled')
    return render_template(
        'tools.html',
        systemwide_notifications_enabled=systemwide_notifications_enabled,
        any_notification_source_available=any_notification_source_available)
示例#4
0
文件: routes.py 项目: imfht/flaskapps
def systemwide_notifications():
    log.debug('systemwide_notifications() called')
    any_notification_source_available = neptune.notifications('systemwide', 'enabled', 'check')
    systemwide_notifications_enabled = neptune.notifications('systemwide', 'enabled', 'enabled')
    systemwide_sms_enabled = neptune.notifications('systemwide', 'sms', 'enabled')
    systemwide_pb_enabled = neptune.notifications('systemwide', 'pb', 'enabled')
    systemwide_email_enabled = neptune.notifications('systemwide', 'email', 'enabled')
    return render_template('systemwide_notifications.html', any_notification_source_available = any_notification_source_available,
                           systemwide_notifications_enabled = systemwide_notifications_enabled,
                           systemwide_sms_enabled = systemwide_sms_enabled,
                           systemwide_pb_enabled = systemwide_pb_enabled,
                           systemwide_email_enabled = systemwide_email_enabled)
示例#5
0
def power_notifications(id):
    zone = f'power{id}'
    log.debug(f'power_notifications() called with powerzone: {zone}')
    systemwide_notifications_enabled = neptune.notifications(
        'systemwide', 'enabled', 'enabled')
    systemwide_sms_enabled = neptune.notifications('systemwide', 'sms',
                                                   'enabled')
    systemwide_pb_enabled = neptune.notifications('systemwide', 'pb',
                                                  'enabled')
    systemwide_email_enabled = neptune.notifications('systemwide', 'email',
                                                     'enabled')
    notifications_enabled = neptune.notifications(zone, 'notifications',
                                                  'enabled')
    sms_enabled = neptune.notifications(zone, 'sms', 'enabled')
    pb_enabled = neptune.notifications(zone, 'pb', 'enabled')
    email_enabled = neptune.notifications(zone, 'email', 'enabled')
    return render_template(
        'power_notifications.html',
        notifications_enabled=notifications_enabled,
        systemwide_notifications_enabled=systemwide_notifications_enabled,
        systemwide_email_enabled=systemwide_email_enabled,
        systemwide_pb_enabled=systemwide_pb_enabled,
        systemwide_sms_enabled=systemwide_sms_enabled,
        sms_enabled=sms_enabled,
        email_enabled=email_enabled,
        pb_enabled=pb_enabled,
        id=id)
示例#6
0
文件: routes.py 项目: imfht/flaskapps
def electrical():
    log.debug('electrical() called')
    electrical_keys = ['dc_voltage', 'dc_current', 'dc_power',
                          'dc_shunt_voltage', 'ac_current', 'ac_voltage']
    electrical_usage_data = {}
    for key in electrical_keys:
        electrical_usage_data[key] = electrical_data('readone', key, 0)

    any_notification_source_available = neptune.notifications('systemwide', 'enabled', 'check')
    systemwide_notifications_enabled = neptune.notifications('systemwide', 'enabled', 'enabled')
    system_sms, system_pb, system_email = neptune.notifications('systemwide', 0, 'check')
    return render_template('electrical.html', any_notification_source_available=any_notification_source_available,
                           systemwide_notifications_enabled=systemwide_notifications_enabled, system_sms=system_sms,
                           system_pb=system_pb, system_email=system_email , **electrical_usage_data)
示例#7
0
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)
示例#8
0
def power(id):
    zone = f'power{id}'
    log.debug(f'power() called with powerzone: {zone}')
    any_zones_running = neptune.any_zones_running('power')
    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])
    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(
        'power.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,
        job_id=job_id,
        id=id,
        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)
示例#9
0
def power_usage_notifications():
    log.debug('power_usage_notifications() called')
    system_sms, system_pb, system_email = neptune.notifications(
        'systemwide', 0, 'check')
    ac_circuit_max_amps_sms = neptune.notifications('ac_circuit_max_amps',
                                                    'sms', 'enabled')
    ac_circuit_max_amps_pb = neptune.notifications('ac_circuit_max_amps', 'pb',
                                                   'enabled')
    ac_circuit_max_amps_email = neptune.notifications('ac_circuit_max_amps',
                                                      'email', 'enabled')
    ac_minimum_volts_sms = neptune.notifications('ac_minimum_volts', 'sms',
                                                 'enabled')
    ac_minimum_volts_pb = neptune.notifications('ac_minimum_volts', 'pb',
                                                'enabled')
    ac_minimum_volts_email = neptune.notifications('ac_minimum_volts', 'email',
                                                   'enabled')
    dc_max_amps_sms = neptune.notifications('dc_max_amps', 'sms', 'enabled')
    dc_max_amps_pb = neptune.notifications('dc_max_amps', 'pb', 'enabled')
    dc_max_amps_email = neptune.notifications('dc_max_amps', 'email',
                                              'enabled')
    dc_minimum_volts_sms = neptune.notifications('dc_minimum_volts', 'sms',
                                                 'enabled')
    dc_minimum_volts_pb = neptune.notifications('dc_minimum_volts', 'pb',
                                                'enabled')
    dc_minimum_volts_email = neptune.notifications('dc_minimum_volts', 'email',
                                                   'enabled')

    form = SetPowerAlertLimitForm()
    form.ac_circuit_max_amps.data = str(
        neptune.get_alert_limit('ac_circuit_max_amps'))
    form.dc_max_amps.data = str(neptune.get_alert_limit('dc_max_amps'))
    form.ac_minimum_volts.data = str(
        neptune.get_alert_limit('ac_minimum_volts'))
    form.dc_minimum_volts.data = str(
        neptune.get_alert_limit('dc_minimum_volts'))

    if form.validate_on_submit():
        neptune.update_alert_limit('ac_circuit_max_amps',
                                   request.form['ac_circuit_max_amps'])
        neptune.update_alert_limit('dc_max_amps', request.form['dc_max_amps'])
        neptune.update_alert_limit('ac_minimum_volts',
                                   request.form['ac_minimum_volts'])
        neptune.update_alert_limit('dc_minimum_volts',
                                   request.form['dc_minimum_volts'])
        flash("Alert Limits Updated", "success")
        return redirect(url_for('power_usage_notifications'))
    else:
        print("Validation Failed")
        print(form.errors)

    return render_template('power_usage_notifications.html',
                           system_sms=system_sms,
                           system_pb=system_pb,
                           system_email=system_email,
                           ac_circuit_max_amps_sms=ac_circuit_max_amps_sms,
                           ac_circuit_max_amps_pb=ac_circuit_max_amps_pb,
                           ac_circuit_max_amps_email=ac_circuit_max_amps_email,
                           ac_minimum_volts_sms=ac_minimum_volts_sms,
                           ac_minimum_volts_pb=ac_minimum_volts_pb,
                           ac_minimum_volts_email=ac_minimum_volts_email,
                           dc_max_amps_sms=dc_max_amps_sms,
                           dc_max_amps_pb=dc_max_amps_pb,
                           dc_max_amps_email=dc_max_amps_email,
                           dc_minimum_volts_sms=dc_minimum_volts_sms,
                           dc_minimum_volts_pb=dc_minimum_volts_pb,
                           dc_minimum_volts_email=dc_minimum_volts_email,
                           form=form)
示例#10
0
def toggle_power_notifications(id, notification):
    zone = f'power{id}'
    log.debug(f'toggle_power_notifications() called with powerzone: {zone}')
    neptune.notifications(zone, notification, 'toggle')
    return redirect(url_for('power_notifications', id=id))
示例#11
0
def toggle_environmental_notifications(zone, notification):
    log.debug(
        f'toggle_environmental_notifications() called with zone: {zone} and: {notification}'
    )
    neptune.notifications(zone, notification, 'toggle')
    return redirect(request.referrer)
示例#12
0
def toggle_systemwide_notifications(type):
    log.debug(f'toggle_systemwide_notifications() called with: {type}')
    neptune.notifications('systemwide', type, 'toggle')
    return redirect(url_for('systemwide_notifications'))