OpenADR VTN Server: Installation and Configuration¶
The OpenADR VTN server is a partial implementation of the OpenADR VTN specification developed by Kisensum for interoperability with the VOLTTRON core VEN agent implementation. The VTN server resides in the VOLTTRON applications repository, and is not supported by the VOLTTRON core team.
Known issues: The Kisensum implementation of the VTN server does not currently include support for registration, including QueryRegistration requests, create and cancel party requests, etc. Additionally, it does not implement opt-in behavior as specified by OpenADR. Finally, it has been found that requests containing empty basic authentication will be served a 403 error, while requests with no authentication will proceed to the correct endpoint normally.
The Kisensum VTN server is a Django application written in Python 3 and utilizing a Postgres database.
If you are planning to install your VTN server on the same system that contains your VOLTTRON instance and you are using RabbitMQ with VOLTTRON, you will need to set up a new instance of RabbitMQ for VTN. In production, the VTN server should be on a different device than VOLTTRON, and as such it is recommended that your VTN server is in it’s own VM or on it’s own machine. If you still wish to set up two instances of RabbitMQ on the same system, please refer to https://www.rabbitmq.com for further details.
Get Source Code¶
To install the VTN server, first get the code by cloning volttron-applications from github and checking out the openadr software.
$ cd ~/repos $ git clone https://github.com/volttron/volttron-applications $ cd volttron-applications $ git checkout master
Install Python 3¶
After installing Python3 on the server, configure an openadr virtual environment:
$ sudo pip install virtualenvwrapper $ mkdir ~/.virtualenvs (if it doesn’t exist already)
Edit ~/.bashrc and add these lines:
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/repos/volttron-applications/kisensum/openadr source virtualenvwrapper.sh
Create the openadr project’s virtual environment:
$ source ~/.bashrc $ mkvirtualenv -p /usr/bin/python3 openadr $ setvirtualenvproject openadr ~/repos/volttron-applications/kisensum/openadr $ workon openadr
From this point on, use workon openadr to operate within the openadr virtual environment.
Create a local site override for Django’s base settings file as follows. First, create ~/.virtualenvs/openadr/.settings in a text editor, adding the following line to it:
Then, edit ~/.virtualenvs/openadr/postactivate, adding the following lines:
PROJECT_PATH=`cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME"` PROJECT_ROOT=`dirname $PROJECT_PATH` PROJECT_NAME=`basename $PROJECT_PATH` SETTINGS_FILENAME=".settings" ENV_FILENAME=".env_postactivate.sh" # Load the default DJANGO_SETTINGS_MODULE from a .settings # file in the django project root directory. export OLD_DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE if [ -f $VIRTUAL_ENV/$SETTINGS_FILENAME ]; then export DJANGO_SETTINGS_MODULE=`cat "$VIRTUAL_ENV/$SETTINGS_FILENAME"` fi
Finally, create $PROJECT_HOME/openadr/openadr/openadr/settings/site.py, which holds overrides to base.py, the Django base settings file. At a minimum, this file should contain the following:
from .base import * ALLOWED_HOSTS = [‘*’]
A more restrictive ALLOWED_HOSTS setting (e.g. ‘ki-evi.com’) should be used in place of ‘*’ if it is known.
Use Pip to Install Third-Party Software¶
$ workon openadr $ pip install -r requirements.txt
Set up a Postgres Database¶
Create a postgres user.
Create a postgres database named openadr.
(The user name, user password, and database name must match what is in $PROJECT_HOME/openadr/openadr/settings/base.py or the override settings in $PROJECT_HOME/openadr/openadr/settings/local.py.)
You may have to edit /etc/postgresql/9.5/main/pg_hba.conf to be ‘md5’ authorization for ‘local’.
Migrate the Database and Create an Initial Superuser¶
$ workon openadr $ cd openadr $ python manage.py migrate $ python manage.py createsuperuser
This is the user that will be used to login to the VTN application for the first time, and will be able to create other users and groups.
rabbitmq is used by celery, which manages the openadr server’s periodic tasks.
Install and run rabbitmq as follows (for further information, see http://www.rabbitmq.com/download.html):
$ sudo apt-get install rabbitmq-server
Start the rabbitmq server if it isn’t already running:
$ sudo rabbitmq-server -detached (note the single dash)
Start the VTN Server¶
$ workon openadr $ cd openadr $ python manage.py runserver 0.0.0.0:8000
$ workon openadr $ cd openadr $ celery -A openadr worker -B
The VTN supports the following configuration parameters, which can be found in base.py and overriden in site.py:
OpenADR ID of this virtual top node. Virtual end nodes must know this VTN_ID to be able to communicate with the VTN.
The amount of time, in minutes, that determines how long the VTN will wait until displaying a given VEN offline. In other words, if the VTN does not receive any communication from a given VEN within ONLINE_INTERVAL_MINUTES minutes, the VTN will display said VEN as offline.
The VTN displays DR Event graph data by averaging individual VENs’ telemetry by GRAPH_TIMECHUNK_SECONDS seconds. This value should be adjusted according to how often VENs are sending the VTN telemetry.