energygame/views.py
def smap_plot_vav(request, mac):
    """Page load definition for VAV statistics."""
    print "inside smap view method"
    context = RequestContext(request)
    if request.method == 'GET':

        device_metadata = [ob.device_control_page_info() for ob in DeviceMetadata.objects.filter(mac_address=mac)]
        print device_metadata
        device_id = device_metadata[0]['device_id']
        device_type_id = device_metadata[0]['device_model_id']
        device_type = device_metadata[0]['device_type']
        device_type_id = device_type_id.device_model_id
        print device_type_id

        device_status = [ob.as_json() for ob in VAV.objects.filter(vav_id=device_id)]
        device_zone = device_status[0]['zone']['id']
        device_nickname = device_status[0]['nickname']
        zone_nickname = device_status[0]['zone']['zone_nickname']

        device_info = str(device_zone) + '/' + device_type + '/' + device_id
        device_info = device_info.encode('ascii', 'ignore')
        device_smap_tag = '/bemoss/' + str(device_zone) + '/' + device_type + '/' + device_id
        device_smap_tag = device_smap_tag.encode('ascii', 'ignore')
        temperature = device_smap_tag + '/temperature'
        supply_temperature = device_smap_tag + '/supply_temperature'
        heat_setpoint = device_smap_tag + '/heat_setpoint'
        cool_setpoint = device_smap_tag + '/cool_setpoint'
        flap_position = device_smap_tag + '/flap_position'
        print temperature

        _uuid_temperature = get_uuid_for_data_point(temperature)
        _uuid_supply_temperature = get_uuid_for_data_point(supply_temperature)
        _uuid_heat_setpoint = get_uuid_for_data_point(heat_setpoint)
        _uuid_cool_setpoint = get_uuid_for_data_point(cool_setpoint)
        _uuid_flap_position = get_uuid_for_data_point(flap_position)

        zones = [ob.as_json() for ob in Building_Zone.objects.all()]
        thermostats_sn = [ob.data_side_nav() for ob in Thermostat.objects.filter(network_status='ONLINE', thermostat_id__bemoss=True)]
        vav_sn = [ob.data_side_nav() for ob in VAV.objects.filter(network_status='ONLINE', vav_id__bemoss=True)]
        rtu_sn = [ob.data_side_nav() for ob in RTU.objects.filter(network_status='ONLINE', rtu_id__bemoss=True)]
        lighting_sn = [ob.data_side_nav() for ob in Lighting.objects.filter(network_status='ONLINE', lighting_id__bemoss=True)]
        plugload_sn = [ob.data_side_nav() for ob in Plugload.objects.filter(network_status='ONLINE', plugload_id__bemoss=True)]
        occ_sensors_sn = [ob.data_side_nav() for ob in OccupancySensor.objects.filter(network_status='ONLINE', occupancy_sensor_id__bemoss=True)]
        lt_sensors_sn = [ob.data_side_nav() for ob in AmbientLightSensor.objects.filter(network_status='ONLINE', ambient_light_sensor_id__bemoss=True)]
        mtn_sensors_sn = [ob.data_side_nav() for ob in MotionSensor.objects.filter(network_status='ONLINE', motion_sensor_id__bemoss=True)]
        powermeters_sn = [ob.data_side_nav() for ob in PowerMeter.objects.filter(network_status='ONLINE', power_meter_id__bemoss=True)]
        active_al = get_notifications()
        context.update({'active_al':active_al})
        context.update({
            'zones': zones, 'thermostat_sn': thermostats_sn,
             'lighting_sn': lighting_sn, 'plugload_sn': plugload_sn, 'occ_sensors_sn': occ_sensors_sn,
             'lt_sensors_sn': lt_sensors_sn, 'mtn_sensors_sn': mtn_sensors_sn,  'powermeters_sn': powermeters_sn,
             'vav_sn': vav_sn, 'rtu_sn': rtu_sn
            })

        rs_temperature = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_temperature)
        rs_supply_temperature = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_supply_temperature)
        rs_heat_setpoint = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_heat_setpoint)
        rs_cool_setpoint = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_cool_setpoint)
        rs_flap_position = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_flap_position)

        return render_to_response(
            'statistics/statistics_vav.html',
            {'temperature': rs_temperature, 'supply_temperature': rs_supply_temperature,
             'flap_position': rs_flap_position, 'heat_setpoint': rs_heat_setpoint, 'cool_setpoint': rs_cool_setpoint,
             'zones': zones, 'mac': mac, 'device_info': device_info,
             'nickname': device_nickname,
             'zone_nickname': zone_nickname},
            context)
Page load definition for VAV statistics.
Page load definition for VAV statistics.
Page load definition for VAV statistics .
def smap_plot_vav(request, mac):
    print "inside smap view method"
    context = RequestContext(request)
    if request.method == 'GET':
        device_metadata = [ob.device_control_page_info() for ob in DeviceMetadata.objects.filter(mac_address=mac)]
        print device_metadata
        device_id = device_metadata[0]['device_id']
        device_type_id = device_metadata[0]['device_model_id']
        device_type = device_metadata[0]['device_type']
        device_type_id = device_type_id.device_model_id
        print device_type_id
        device_status = [ob.as_json() for ob in VAV.objects.filter(vav_id=device_id)]
        device_zone = device_status[0]['zone']['id']
        device_nickname = device_status[0]['nickname']
        zone_nickname = device_status[0]['zone']['zone_nickname']
        device_info = str(device_zone) + '/' + device_type + '/' + device_id
        device_info = device_info.encode('ascii', 'ignore')
        device_smap_tag = '/bemoss/' + str(device_zone) + '/' + device_type + '/' + device_id
        device_smap_tag = device_smap_tag.encode('ascii', 'ignore')
        temperature = device_smap_tag + '/temperature'
        supply_temperature = device_smap_tag + '/supply_temperature'
        heat_setpoint = device_smap_tag + '/heat_setpoint'
        cool_setpoint = device_smap_tag + '/cool_setpoint'
        flap_position = device_smap_tag + '/flap_position'
        print temperature
        _uuid_temperature = get_uuid_for_data_point(temperature)
        _uuid_supply_temperature = get_uuid_for_data_point(supply_temperature)
        _uuid_heat_setpoint = get_uuid_for_data_point(heat_setpoint)
        _uuid_cool_setpoint = get_uuid_for_data_point(cool_setpoint)
        _uuid_flap_position = get_uuid_for_data_point(flap_position)
        zones = [ob.as_json() for ob in Building_Zone.objects.all()]
        thermostats_sn = [ob.data_side_nav() for ob in Thermostat.objects.filter(network_status='ONLINE', thermostat_id__bemoss=True)]
        vav_sn = [ob.data_side_nav() for ob in VAV.objects.filter(network_status='ONLINE', vav_id__bemoss=True)]
        rtu_sn = [ob.data_side_nav() for ob in RTU.objects.filter(network_status='ONLINE', rtu_id__bemoss=True)]
        lighting_sn = [ob.data_side_nav() for ob in Lighting.objects.filter(network_status='ONLINE', lighting_id__bemoss=True)]
        plugload_sn = [ob.data_side_nav() for ob in Plugload.objects.filter(network_status='ONLINE', plugload_id__bemoss=True)]
        occ_sensors_sn = [ob.data_side_nav() for ob in OccupancySensor.objects.filter(network_status='ONLINE', occupancy_sensor_id__bemoss=True)]
        lt_sensors_sn = [ob.data_side_nav() for ob in AmbientLightSensor.objects.filter(network_status='ONLINE', ambient_light_sensor_id__bemoss=True)]
        mtn_sensors_sn = [ob.data_side_nav() for ob in MotionSensor.objects.filter(network_status='ONLINE', motion_sensor_id__bemoss=True)]
        powermeters_sn = [ob.data_side_nav() for ob in PowerMeter.objects.filter(network_status='ONLINE', power_meter_id__bemoss=True)]
        active_al = get_notifications()
        context.update({'active_al':active_al})
        context.update({
            'zones': zones, 'thermostat_sn': thermostats_sn,
             'lighting_sn': lighting_sn, 'plugload_sn': plugload_sn, 'occ_sensors_sn': occ_sensors_sn,
             'lt_sensors_sn': lt_sensors_sn, 'mtn_sensors_sn': mtn_sensors_sn,  'powermeters_sn': powermeters_sn,
             'vav_sn': vav_sn, 'rtu_sn': rtu_sn
            })
        rs_temperature = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_temperature)
        rs_supply_temperature = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_supply_temperature)
        rs_heat_setpoint = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_heat_setpoint)
        rs_cool_setpoint = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_cool_setpoint)
        rs_flap_position = get_data_from_smap("http://localhost/backend/api/data/uuid/" + _uuid_flap_position)
        return render_to_response(
            'statistics/statistics_vav.html',
            {'temperature': rs_temperature, 'supply_temperature': rs_supply_temperature,
             'flap_position': rs_flap_position, 'heat_setpoint': rs_heat_setpoint, 'cool_setpoint': rs_cool_setpoint,
             'zones': zones, 'mac': mac, 'device_info': device_info,
             'nickname': device_nickname,
             'zone_nickname': zone_nickname},
            context)
def smap_plot_vav ( request , mac ) : print "inside smap view method" context = RequestContext ( request ) if request . method == 'GET' : device_metadata = [ ob . device_control_page_info ( ) for ob in DeviceMetadata . objects . filter ( mac_address = mac ) ] print device_metadata device_id = device_metadata [ 0 ] [ 'device_id' ] device_type_id = device_metadata [ 0 ] [ 'device_model_id' ] device_type = device_metadata [ 0 ] [ 'device_type' ] device_type_id = device_type_id . device_model_id print device_type_id device_status = [ ob . as_json ( ) for ob in VAV . objects . filter ( vav_id = device_id ) ] device_zone = device_status [ 0 ] [ 'zone' ] [ 'id' ] device_nickname = device_status [ 0 ] [ 'nickname' ] zone_nickname = device_status [ 0 ] [ 'zone' ] [ 'zone_nickname' ] device_info = str ( device_zone ) + '/' + device_type + '/' + device_id device_info = device_info . encode ( 'ascii' , 'ignore' ) device_smap_tag = '/bemoss/' + str ( device_zone ) + '/' + device_type + '/' + device_id device_smap_tag = device_smap_tag . encode ( 'ascii' , 'ignore' ) temperature = device_smap_tag + '/temperature' supply_temperature = device_smap_tag + '/supply_temperature' heat_setpoint = device_smap_tag + '/heat_setpoint' cool_setpoint = device_smap_tag + '/cool_setpoint' flap_position = device_smap_tag + '/flap_position' print temperature _uuid_temperature = get_uuid_for_data_point ( temperature ) _uuid_supply_temperature = get_uuid_for_data_point ( supply_temperature ) _uuid_heat_setpoint = get_uuid_for_data_point ( heat_setpoint ) _uuid_cool_setpoint = get_uuid_for_data_point ( cool_setpoint ) _uuid_flap_position = get_uuid_for_data_point ( flap_position ) zones = [ ob . as_json ( ) for ob in Building_Zone . objects . all ( ) ] thermostats_sn = [ ob . data_side_nav ( ) for ob in Thermostat . objects . filter ( network_status = 'ONLINE' , thermostat_id__bemoss = True ) ] vav_sn = [ ob . data_side_nav ( ) for ob in VAV . objects . filter ( network_status = 'ONLINE' , vav_id__bemoss = True ) ] rtu_sn = [ ob . data_side_nav ( ) for ob in RTU . objects . filter ( network_status = 'ONLINE' , rtu_id__bemoss = True ) ] lighting_sn = [ ob . data_side_nav ( ) for ob in Lighting . objects . filter ( network_status = 'ONLINE' , lighting_id__bemoss = True ) ] plugload_sn = [ ob . data_side_nav ( ) for ob in Plugload . objects . filter ( network_status = 'ONLINE' , plugload_id__bemoss = True ) ] occ_sensors_sn = [ ob . data_side_nav ( ) for ob in OccupancySensor . objects . filter ( network_status = 'ONLINE' , occupancy_sensor_id__bemoss = True ) ] lt_sensors_sn = [ ob . data_side_nav ( ) for ob in AmbientLightSensor . objects . filter ( network_status = 'ONLINE' , ambient_light_sensor_id__bemoss = True ) ] mtn_sensors_sn = [ ob . data_side_nav ( ) for ob in MotionSensor . objects . filter ( network_status = 'ONLINE' , motion_sensor_id__bemoss = True ) ] powermeters_sn = [ ob . data_side_nav ( ) for ob in PowerMeter . objects . filter ( network_status = 'ONLINE' , power_meter_id__bemoss = True ) ] active_al = get_notifications ( ) context . update ( { 'active_al' : active_al } ) context . update ( { 'zones' : zones , 'thermostat_sn' : thermostats_sn , 'lighting_sn' : lighting_sn , 'plugload_sn' : plugload_sn , 'occ_sensors_sn' : occ_sensors_sn , 'lt_sensors_sn' : lt_sensors_sn , 'mtn_sensors_sn' : mtn_sensors_sn , 'powermeters_sn' : powermeters_sn , 'vav_sn' : vav_sn , 'rtu_sn' : rtu_sn } ) rs_temperature = get_data_from_smap ( "http://localhost/backend/api/data/uuid/" + _uuid_temperature ) rs_supply_temperature = get_data_from_smap ( "http://localhost/backend/api/data/uuid/" + _uuid_supply_temperature ) rs_heat_setpoint = get_data_from_smap ( "http://localhost/backend/api/data/uuid/" + _uuid_heat_setpoint ) rs_cool_setpoint = get_data_from_smap ( "http://localhost/backend/api/data/uuid/" + _uuid_cool_setpoint ) rs_flap_position = get_data_from_smap ( "http://localhost/backend/api/data/uuid/" + _uuid_flap_position ) return render_to_response ( 'statistics/statistics_vav.html' , { 'temperature' : rs_temperature , 'supply_temperature' : rs_supply_temperature , 'flap_position' : rs_flap_position , 'heat_setpoint' : rs_heat_setpoint , 'cool_setpoint' : rs_cool_setpoint , 'zones' : zones , 'mac' : mac , 'device_info' : device_info , 'nickname' : device_nickname , 'zone_nickname' : zone_nickname } , context )
Page load definition for VAV statistics.
Page load definition for VAV statistics .
"""Page load definition for VAV statistics."""
request
mac