Brick Server is an implementation of Brick API on top of a timeseries database (TimescaleDB) and a Brick database (Virtuoso). Data in buildings are represented as streams of timestamped-values generated from Points which may record a physical property or actuate a device. Metadata helps to find the right data streams that an application needs. Data and metadata are in different formats, and thus we have to store them in different databases. Brick Server provides a single API endpoint to access those two different data sources.
Brick Server is
- a minimal but fully functional Bulding Operating System (BOS),
- an interface for Brick applications,
- an emulator of a building for Brick applications development,
- a demonstration of general methods to integrate your system with Brick, and
- a testbed for new functions in Brick.
If you want to learn more about Brick, please visit brickschema.org for materials.
- OS: Linux (tested over Ubuntu 18.04 and Debian 9.)
- Python 3.6>= is required.
-
Configure
config.json
.- Change
configs/configs.json.template
toconfigs/configs.json
- Modify the configuration in
configs/configs.json
.- The preset parameters are working with the default docker-compose file.
- You can ignore
oauth_connections
andfrontend
as they currently under development.
- Change
-
Configure
docker-compose.yml
- Change
docker-compose.yml.template
todocker-compose.yml
. - Modify the configuration in
docker-compose.yml
.- Choose if you want to run https inside the docker. You can enable HTTPS by uncommenting
ENABLE_SSL=true
. In that case, you should specify the location of cert files (CERTFILE
andKEYFILE
)as well as bind the files from the host machine (e.g.,/etc/letsencrypt
.). - You can further configure
brickserver
module for more optimization. The current image usesgunicorn
as a web server anduvicorn
as an ASGI. Please refer to the image's doc for more information.
- Choose if you want to run https inside the docker. You can enable HTTPS by uncommenting
- Change
-
Run docker-compose
- Execute
docker-compose up
.
- Execute
-
Get an App Token.
- Execute
docker exec -t brickserver /app/tools/get_jwt_token
. - Keep and use it as a bearer token.
- Execute
- Install and run Virtuoso (Note: Please use only released versions in Virtuoso repository. link)
- Install and run TimescaleDB/PostGIS/PostgreSQL. link
- Install pip packages by
pip install -r requirements.txt
- Configure the databases and configure
configs/configs.json
- Create a database with a proper name in the db.
- Create a role/user of the database.
- Add them inside
configs/configs.json
- Run
python entry.py
to run the server. - Run
python examples/test_api.py
in another console. - API Documentation would be available at https://localhost/api/v1/doc
- Install and run the fronted based on its instruction: https://gitlab.com/jbkoh/brick-server-frontend
- API document is available at
YOUR_HOSTNAME/docs
- Example codes are available at
tests/remote/*.py
- Jupyter Notebooks will be available.
- An entity (sensor, room, VAV, etc.) is represented by its UUID under the UUID namespace.
- E.g.,
- An entity is an instance of at least one Brick Class. The Brick Class can be arbitrary even outside the standard though not preferred.
- An entity can have relationships with other entities.
- An entity's metadata consists of its direct relationships with other entities (or properties.)
- The database schema of timeseries data is a long table with four columns of
uuid
,timestamp
,number
, andtext
where the combinations ofuuid
andtimestamp
are unique.number
andtext
are the data types that each entity can have. Usually an entity may have only one data type for its values. - Each row is a timestamped value.
- The
uuids
in the timeseries database are the same uuids in Brick.
- Currently, we only support a very primitive authorization. A user can manually generate a JWT token with the privkey used in Brick Server, which can be used as a bearer token. The token will authorize the usage of any APIs until it expires.
- You can get it through
tools/get_jwt_token $expiration_time_in_seconds
.
- You can get it through
- You can retrieve the public key at
/auth/jwt_pubkey
.
- Add a JWT token into
pytest.ini
. - Execute
pytest -c pytest.ini tests/remote
.
- Prepare an app token.
- Check the instruction at TODO
- Integration with Traefik
- Implementation of full authorization.
- Metadata Models and Methods for Smart Buildings (Dissertation, UCSD, 2020)
- Who, What, and When (BuildSys 2019)
- Brick+ (BuildSys 2019)
- MortarData (BuildSys 2018)
- Brick (EnergyPlus 2018)
- Brick (BuildSys 2016)