This repository hosts a set of libraries and command line tool for automating parts of the onboarding workflow. It gives the user the ability to apply rule-based mapping automation, ingest multiple source files, review loadsheet consistency, and validate entity definitions against a pre-defined ontology (i.e., Google's Digital Buildings Ontology).
This repo contains the following critical pieces:
- A well defined ontology (
./ontology
) - A command line interface for dynamically building and checking loadsheets (
./programs/cli.py
) - Associated support libraries for the command line interface (and for future enhancement):
- An ontology validator
- A loadsheet validator
- A handler class that sits atop all the relevant classes
- A rules engine for applying regular expression pattern matching
- A representations class set for converting the loadsheet into ontology-usable objects
This repo requires the following libraries to be installed prior to use:
- pyyaml (for parsing YAML documents)
- pyfiglet (for fancy CLI name)
- openpyxl (for Excel read/write)
- pandas (for loadsheet backend)
- ruamel.yaml
If not already installed, you can install the libraries by running requirements.py
in your command line:
>>> python requirements.py
General Loadsheet Process
- Prepare the loadsheet
- Obtain a point list (in XSLX or CSV format)
- Format the point list to adhere to the loadsheet template sheet
- Run the rule engine over the data
- Manually review the unmapped points
- Validate the loadsheet
- Match the entities in the loadsheet to existing DBO types
- Create new types in the referenced ontology, as needed
- Apply matched DBO types to the loadsheet
From your command prompt (or euivalent console) run the progam (note that python
is used here, but your local machine may use py
, py3
, or python3
).
python cli.py
Once the LoadBoy2000 program starts, pass in a path (absolute or relative) to the ontology that the program will reference during validation and type matching. If successful, you should get CLI confirmation.
import ontology '../ontology/yaml/resources'
This step is only required if you are passing in a raw points list (directly exported from an ALC BMS).
clean '../loadsheet/Loadsheet_ALC.xlsx'
Step 4 - Import the loadsheet (either the "clean" output from Step 3 or a previously "cleaned" loadsheet)
Load the loadsheet that you want to validate, normalized, and type match. If successful, you should get CLI confirmation.
import loadsheet '../loadsheet/Loadsheet_ALC.xlsx'
Apply reular expression rules to populate the standardFieldName column. The default ruleset uses DBO field names. If successful, you should get CLI confirmation.
normalize '../resources/rules/google_rules.json'
Once rules are successfully applied, you should see a new file with normalized columns (e.g., required
, assetName
, and standardFieldName
) filled in.
export excel '../loadsheet/Loadsheet_ALC_Normalized.xlsx'
Perform a manual review to ensure that the applied standardFieldNames are correct. Correct any incorrect field names, remove any field names that are not relevant to the model (e.g., PID inputs) by marking the reqired
column as "NO", and add any field names that were not populated but are relevant to the model by marking the required
column as "YES".
Import the loadsheet (after manual review from Step 7) that has the standardFieldName column populated for fields of interest.
import loadsheet '../loadsheet/Loadsheet_ALC_Final.xlsx'
Run validation over the loadsheet
validate
Validation will fail for common errors:
- Duplicate
standardFieldName
andfullAssetPath
combinations (i.e., twozone_air_temperature_sensor
fields for VAV-123) - An invalid
standardFieldName
(i.e., not defined in the referenced ontology, mispelled, etc.) - Missing BACnet info in the columns (e.g., blank
objectId
)
When no validation errors are present, assets in the loadsheet can be matched to DBO entity types. Matching attempts to find the closest canonical type in the DBO that has the same fieldset as the asset in the loadsheet.
match
You can review all DBO general types found in the loadsheet (i.e., AHU, VAV, FCU, etc.)
review generalTypes
Or, you can review specific DBO general types found in the loadsheet
review generalTypes VAV
Or, you can review sub-sets (distinct field sets) of general types found in the loadsheet
review generalTypes VAV 1
Or, you can review matched types (i.e., the field set in the loadsheet matched to a DBO type TODO: verify this is the behavior of this command
review matches
TODO: explain match types in detail
- You can review all matches (close, incomplete, and exact) using
apply all
apply all
- OR you can auto-apply "exact" matches and only review inexact (close and imcomplete) using
apply close
apply close
TODO: write this section
TODO: write more here, this command requires additional input of the raw deiscovery results
import payload 'path/to/payload.csv'
convert abel
The ABEL formatted spreadsheet will be exported to the same directory as the loadsheet with suffix "_abel".
The following is a list of issues that need to be addressed before widespread use:
- Add rigorous typing to all methods
- Make the necessary fields in
handler.py
andrepresentations.py
private - Increase the match success rate of the rules JSON (and potentially provide tooling or templates for users to create their own ruleset)
- Expand to type match to more domains (currently only HVAC)
Manual (optional) unit tests:
- Add a fake field with invalid subfields
bacon_sensor
to the ontology field list (../resources/fields/telemetry_fields.yaml) -- should return error - Add a fake field with valid subfields
supply_sensor
to the ontology field list (../resources/fields/telemetry_fields.yaml) -- will NOT return an error. - Add a new abstract type with a fake field -- should return error
- Add duplicate fields to fake abstract type -- should return error