Beispiel #1
0
def get_request_df(room):
    row = rooms_and_sensors[rooms_and_sensors['Label'] == str(room)]

    if not row.empty:
        try:
            temp_value, temp_units = get_value(row['Facility'].iloc[0],
                                               row['Temperature'].iloc[0],
                                               True)
            co2_value, co2_units = get_value(row['Facility'].iloc[0],
                                             row['CO2'].iloc[0], True)
        except requests.exceptions.ConnectionError:
            raise ConnectionError(
                "Unable to get data. Are you connected to the right WiFi network?"
            )
        # Prepare to print
        temp_value = int(temp_value) if temp_value else ''
        temp_units = temp_units if temp_units else ''
        co2_value = int(co2_value) if co2_value else ''
        co2_units = co2_units if co2_units else ''

        df_dictionary = {
            'room': [room if temp_value and temp_units else ''],
            # If there's no data, leave the dictionary empty so the failsafe below catches it
            'temperature': [temp_value],
            'temperature units': [temp_units],
            'co2': [co2_value],
            'co2 units': [co2_units]
        }

        if not df_dictionary:
            return None

        return pd.DataFrame.from_dict(df_dictionary)
    else:
        return None
Beispiel #2
0
def save_baseline( csv_filename, column_name, oid_row ):

    # Retrieve data, retrying if necessary
    facility = oid_row['Facility']
    oid = oid_row[column_name]
    row_label = oid_row['Label']
    for i in range( 1, 6 ):
        value, units = get_value( facility, oid, args.hostname, args.port, live=True )
        value = int( value )
        view_id, column_id, row_id = baselines_db.save_baseline_value( csv_filename, column_name, row_label, value, units, timestamp_id )
        report_baseline( view_id, column_id, row_id, row_label, value, units, facility, oid )
        break
Beispiel #3
0
def ReadAllMeters():
    # Iterate over the rows of the dataframe, getting temperature and CO2 values for each Feeder
    for index, row in df.iterrows():

        # Retrieve data
        kW_value, kW_units = get_value(row['Facility'], row['Power'],
                                       args.hostname, args.port)
        kWh_value, kWh_units = get_value(row['Facility'], row['Energy'],
                                         args.hostname, args.port)
        currentDT = datetime.datetime.now()

        # Prepare to print
        kW_value = round(float(kW_value)) if kW_value else ''
        kW_units = kW_units if kW_units else ''
        kWh_value = round(float(kWh_value)) if kWh_value else ''
        kWh_units = kWh_units if kWh_units else ''

        # Output CSV format
        print('{0},{1},{2},{3},{4},{5}'.format(
            currentDT.strftime("%Y-%m-%d %H:%M:%S"), row['Label'], kW_value,
            kW_units, kWh_value, kWh_units))
Beispiel #4
0
# Copyright 2018 Building Energy Gateway.  All rights reserved.

import time
import numbers
from building_data_requests import get_value
from simple_power_request import request_list

start_time = time.time()

# Iterate through list of requests
for request in request_list:

    # Issue next request
    value, units = get_value(request['facility'], request['instance'])

    # Prepare to print results
    value = int(value) if isinstance(value, numbers.Number) else ''
    units = units if units else ''

    # Output result
    print('{0}: {1} {2}'.format(request['label'], value, units))

# Report elapsed time
elapsed_time = round((time.time() - start_time) * 1000) / 1000
print('\nElapsed time: {0} seconds'.format(elapsed_time))
Beispiel #5
0
# Copyright 2018 Building Energy Gateway.  All rights reserved.

from building_data_requests import get_value

value, units = get_value('ahs', 3007360)
print('AHS Main: {0} {1}'.format(int(value), units))

temp_value, temp_units = get_value('ahs', 3001489)
co2_value, co2_units = get_value('ahs', 3001477)
print('AHS 351: {0} {1} | CO2 {2} {3}'.format(int(temp_value), temp_units,
                                              int(co2_value), co2_units))
    #   - Label
    #   - Facility
    #   - Instance ID of CO2 sensor
    #   - Instance ID of temperature sensor
    df = pd.read_csv('ahs_air.csv', na_filter=False, comment='#')

    # Output column headings
    print('Location,Temperature,Temperature Units,CO2,CO2 Units')

    with open('ahs_air_data.csv', mode='w') as ahs_air_data:
        temp_writer = csv.writer(ahs_air_data, delimiter=";")
        # Iterate over the rows of the dataframe, getting temperature and CO2 values for each location
        for index, row in df.iterrows():

            # Retrieve data
            temp_value, temp_units = get_value(row['Facility'],
                                               row['Temperature'])
            co2_value, co2_units = get_value(row['Facility'], row['CO2'])

            # Prepare to print
            temp_value = int(temp_value) if isinstance(temp_value,
                                                       numbers.Number) else ''
            temp_units = temp_units if temp_units else ''
            co2_value = int(co2_value) if isinstance(co2_value,
                                                     numbers.Number) else ''
            co2_units = co2_units if co2_units else ''

            # Output CSV format

            temp_writer.writerow([
                '{0},{1},{2},{3},{4}'.format(row['Label'], temp_value,
                                             temp_units, co2_value, co2_units)
Beispiel #7
0
# Copyright 2018 Building Energy Gateway.  All rights reserved.

from building_data_requests import get_value

value, units = get_value('ahs-ws', 'temperature')
print('AHS Weather Station - Temperature: {0} {1}'.format(value, units))
Beispiel #8
0
import pandas as pd
from building_data_requests import get_value
import numbers

start_time = time.time()

# Read spreadsheet into a dataframe.
# Each row contains the following:
#   - Label
#   - Facility
#   - Instance ID of electric meter
df = pd.read_csv('../csv/aps_power.csv')
df = df.sort_values(by='Label', ascending=True)

# Iterate over dataframe, getting values for each row
for index, row in df.iterrows():

    # Retrieve data
    value, units = get_value(row['Facility'], row['Meter'])

    # Prepare to print
    value = int(value) if isinstance(value, numbers.Number) else ''
    units = units if units else ''

    # Output result
    print('{0}: {1} {2}'.format(row['Label'], value, units))

# Report elapsed time
elapsed_time = round((time.time() - start_time) * 1000) / 1000
print('\nElapsed time: {0} seconds'.format(elapsed_time))
 def get_value(self):
     return get_value(self.facility, self.sensor)
Beispiel #10
0
from pylive import live_plotter_xy, get_plot
import numpy as np
import time

import sys

sys.path.insert(1, '/home/justin/PycharmProjects/buildingEnergyApi/py')
from building_data_requests import get_value

x_vec = np.full(1, 0)
kW, units = get_value('ahs', 3007360)
y_vec1 = np.full(len(x_vec), int(kW))

# kW, units = get_value('west_middle-12', 3027266) # West Middle
# y_vec2 = np.full(len(x_vec), int(kW))
line1 = []
# line2 = []

wait_time = 5  # seconds
elapsed_time = 0

while True:
    kW, units = get_value('ahs', 3007360)
    y_vec1 = np.append(y_vec1, int(kW))
    x_vec = np.append(int(x_vec[0] - wait_time), x_vec)

    # kW, units = get_value('west_middle-12', 3027266)  # West Middle
    # y_vec2 = np.append(y_vec2, int(kW))

    line1 = live_plotter_xy(x_vec,
                            y_vec1,
 def get_value(self, index):
     # queries using facility and meter
     value, self.units = get_value(self.sensors[index][1], self.sensors[index][2])
     return value
Beispiel #12
0
    # Read spreadsheet into a dataframe.
    # Each row contains the following:
    #   - Location
    #   - Instance ID of CO2 sensor
    #   - Instance ID of temperature sensor
    df = pd.read_csv( '../csv/ahs_air.csv', na_filter=False, comment='#' )

    # Output column headings
    print( 'Location,Temperature,Temperature Units,CO2,CO2 Units' )

    # Iterate over the rows of the dataframe, getting temperature and CO2 values for each location
    for index, row in df.iterrows():

        # Retrieve data
        temp_value, temp_units = get_value( row['Facility'], row['Temperature'], args.hostname, args.port )
        co2_value, co2_units = get_value( row['Facility'], row['CO2'], args.hostname, args.port )

        # Prepare to print
        temp_value = round( float( temp_value ) ) if temp_value else ''
        temp_units = temp_units if temp_units else ''
        co2_value = round( float( co2_value ) ) if co2_value else ''
        co2_units = co2_units if co2_units else ''

        # Output CSV format
        print( '{0},{1},{2},{3},{4}'.format( row['Label'], temp_value, temp_units, co2_value, co2_units ) )

except KeyboardInterrupt:
    print( 'Bye' )
    sys.exit()