def pandas_numpy_practice():
	print("Number Practice!")
	the_config = Config()
	the_data_app = Ds_App(the_config)
	sensor_name = "upper_sensor"
	the_average = the_data_app.get_rolling_avg_temp(sensor_name)
	print("The rolling average is: {}".format(the_average))
async def process_sensor_4():
    global sensor4
    sensor4.process_sensor()
    sensor_data = sensor4.get_current_data()
    database = Ds_App(config)
    is_good = database.verify_sensor_data(sensor_data)
    if is_good:
        database.write_sensor_data(sensor_data)
Example #3
0
def index():

    config = Config()
    data_app = Ds_App(config)
    _title = 'RPiii Environment Controller'
    sensor_name = "plant1"
    previous_minutes_back = 60

    graphConfig = forms.GraphConfigForm()
    if graphConfig.validate_on_submit():
        minutes = graphConfig.time.data
        sensor_name = graphConfig.sensor_name.data
        previous_minutes_back = minutes

    readings = data_app.get_previous_readings_time(previous_minutes_back,
                                                   sensor_name)
    global temp_arr, time_arr, hum_arr
    temp_arr = []
    time_arr = []
    hum_arr = []
    for reading in readings:
        temp_arr.append(reading.temperature)
        hum_arr.append(reading.humidity)
        time_arr.append(reading.time_stamp)

    control_stats = data_app.get_previous_control_stats(previous_minutes_back)
    global control_time, heater_state, humidifier_state, fan_state, light_state
    control_time = []
    heater_state = []
    humidifier_state = []
    fan_state = []
    light_state = []
    for control_stat in control_stats:
        control_time.append(control_stat.time_stamp)
        heater_state.append(control_stat.heater_state)
        humidifier_state.append(control_stat.humidifier_state)
        fan_state.append(control_stat.fan_state)
        light_state.append(control_stat.light_state)

    last_rec = readings[-1]
    _data = [
        last_rec.temperature, last_rec.humidity, last_rec.time_stamp,
        last_rec.sensor
    ]

    return render_template('index.html',
                           title=_title,
                           data=_data,
                           form=graphConfig)
Example #4
0
def Initialize_Control(config):
    print("Processing         : Initializing Control Objects")
    global the_time, the_heater, the_humidifier, the_fan, the_light, the_config, data_app
    the_config = config
    the_time = OS_Clock()
    the_heater = Heater()
    the_humidifier = Humidifier()
    the_fan = Fan()
    the_light = Light()
    data_app = Ds_App(config)
    print("Processing         : Control Objects Initialized")