Skip to content

newbie tips #111

@bbartling

Description

@bbartling

Hello,

Can I use py-brickshema to make a Brick model or would I only be using py-brickshema in validating an existing Brick model? Apologize for my ignorance I have a lot to learn...

I am working with configuration files like this below in YAML format that represent a BACnet devices inside a building:

devices:
- address: '12:40'
  device_identifier: '601040'
  device_name: MTR-01 BACnet
  points:
  - object_identifier: analog-input,8
    object_name: Outlet Setp. 1
  - object_identifier: analog-input,9
    object_name: Outlet Temp. 1
  - object_identifier: analog-input,10
    object_name: Inlet Temp. 1
  - object_identifier: analog-input,11
    object_name: Flue1/Pool Temp.
  - object_identifier: analog-input,11
    object_name: Firing Rate 1
  read_multiple: true
  scrape_interval: 600

Which I can modify at will. I am taking a stab in the dark at what it would look like in Brick...? Assuming people starting out are just manually adding the meta data into there processes?..

devices:
  - address: '12:40'
    device_identifier: '601040'
    device_name: MTR-01 BACnet
    type: Boiler_Controller
    points:
      - object_identifier: analog-input,8
        object_name: Outlet Setpoint 1
        brick_class: Setpoint
        brick_function: Temperature
        brick_location: Boiler_Outlet
      - object_identifier: analog-input,9
        object_name: Outlet Temp 1
        brick_class: Sensor
        brick_function: Temperature
        brick_location: Boiler_Outlet
      - object_identifier: analog-input,10
        object_name: Inlet Temp 1
        brick_class: Sensor
        brick_function: Temperature
        brick_location: Boiler_Inlet
      - object_identifier: analog-input,11
        object_name: Flue1/Pool Temp
        brick_class: Sensor
        brick_function: Temperature
        brick_location: Flue
      - object_identifier: analog-input,11
        object_name: Firing Rate 1
        brick_class: Sensor
        brick_function: Firing_Rate
        brick_location: Boiler
    read_multiple: true
    scrape_interval: 600

Where I then I can read it into Python with a script something like this:

import yaml

def read_bacnet_config(file_path):
    with open(file_path, 'r') as file:
        config = yaml.safe_load(file)
        return config

def print_device_attributes(device_config):
    for device in device_config['devices']:
        print(f"Device Name: {device['device_name']}")
        print(f"Device Identifier: {device['device_identifier']}")
        print(f"Device Address: {device['address']}")
        print("Points:")
        for point in device['points']:
            print(f"  - Object Name: {point['object_name']}")
            print(f"    Object Identifier: {point['object_identifier']}")
            if 'brick_class' in point:
                print(f"    Brick Class: {point['brick_class']}")
            if 'brick_function' in point:
                print(f"    Brick Function: {point['brick_function']}")
            if 'brick_location' in point:
                print(f"    Brick Location: {point['brick_location']}")

# Example usage
config_file_path = '201201_brick.yml'
config = read_bacnet_config(config_file_path)
print_device_attributes(config)

I am still trying to figure out how to properly implement a Brick model manually on some BAS devices inside a building through config files like this and where py-brickschema would fit into the process. Any tips greatly appreciated.

For this building there would also be similar config files for VAV boxes, AHU, and a chiller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions