Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After bulk config merge #10

Closed
wants to merge 104 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
259ae7f
Added improved handling of boolean registers and default type handlin…
davidraker Sep 21, 2023
1e5e995
replaced hardcoded port with random available ports.
schandrika Sep 26, 2023
b403411
replaced hardcoded port with random available ports(issue #3119)
schandrika Sep 26, 2023
5c0ab06
Merge pull request #3120 from schandrika/test_fix
schandrika Sep 26, 2023
18b03e9
Initial version of bulk update of config store when volttron is not r…
schandrika Sep 26, 2023
1b0f496
minor log stmt fix
schandrika Sep 26, 2023
f01872b
First git push to new repo using ssh
riley206 May 25, 2023
13f0bd0
Control multiple thermostats and convert F to C to change temps
riley206 May 30, 2023
a014ae3
Testing to make sure I can comit and push from vs
riley206 May 30, 2023
8757959
Updated registers file and removed comments
riley206 Jun 5, 2023
3d32f41
Cleaned up code
riley206 Jun 6, 2023
0de1673
Create HomeAssistantDriver.md
riley206 Jun 6, 2023
01c8095
Update HomeAssistantDriver.md
riley206 Jun 6, 2023
4dd3ffb
Updated documentaion, added strip for entity IDs
riley206 Jun 7, 2023
f9cfba4
Driver responds to changes from other agents
riley206 Jun 21, 2023
ebd3384
Fixed get_point function and updated the Readme file to reflect recen…
riley206 Jun 26, 2023
a73293e
Updated config file and readme
riley206 Jun 26, 2023
eb9c7e6
Expirimenting with different ways of publishing data
riley206 Aug 16, 2023
e478699
Changed publish mechanism for individual devices
riley206 Aug 23, 2023
e8c0707
Changed keys when publishing state
riley206 Aug 30, 2023
8fa2d2d
replaced entity_id with register.point_name to simplify
riley206 Sep 5, 2023
9ed92ac
Added functionality to control lights correctly in set_point
riley206 Sep 5, 2023
5445d47
Removed subscription function
riley206 Sep 5, 2023
0d9de41
added light on/off functionality in _set_point
riley206 Sep 5, 2023
1edc80c
brightness being treated like state, brightness control
riley206 Sep 6, 2023
b66cfb0
Seperated attributes from points
riley206 Sep 7, 2023
3b45eb9
Seperated Entity ID and Point name
riley206 Sep 12, 2023
bec8eff
Updated Readme to match changes
riley206 Sep 12, 2023
60c5824
cleaned up HomeAssistantRegister class
riley206 Sep 12, 2023
0b3f073
Cleaned up configure method
riley206 Sep 12, 2023
54c05fa
Removed unused key
riley206 Sep 12, 2023
daa9066
Added none checks and ValueError for essential config values
riley206 Sep 12, 2023
e9231bf
Removed old files
riley206 Sep 12, 2023
6733b79
Added example config files
riley206 Sep 12, 2023
9878f55
Checking its a light entity before changing points
riley206 Sep 13, 2023
f36bf24
Added thermostat support
riley206 Sep 19, 2023
643306b
Updated readme for thermostats
riley206 Sep 19, 2023
85e0576
added some error checking
riley206 Sep 19, 2023
98f2ef5
Updated light state to reflect ints
riley206 Sep 26, 2023
17c884b
climate off state changed to 0
riley206 Sep 28, 2023
d3effd4
removed example files in replacement for better docs
riley206 Sep 28, 2023
6718bf4
changed entity_id source to config file
riley206 Sep 28, 2023
3d92076
Updated docs to reflect new configuration structure
riley206 Sep 28, 2023
094e79d
reverted back to orignal structure
riley206 Sep 28, 2023
aa5a908
updated docs
riley206 Sep 28, 2023
dc46edd
updated md to rst
riley206 Sep 28, 2023
668ec4a
removed rst
riley206 Sep 29, 2023
cd2b401
Moved reademe to docs/source/agent-framework/driver-framework/home-as…
riley206 Sep 29, 2023
110c643
added HomeAssitant docs path
riley206 Sep 29, 2023
808567a
replaced HomeAssistantDriver.md with HomeAssistantDriver.rst
riley206 Sep 29, 2023
9d87154
Added limitations to docs
riley206 Sep 29, 2023
4cd76ca
removed print statements
riley206 Sep 29, 2023
a411c9b
correct initial test_home_assistant.py
schandrika Sep 30, 2023
bea4885
Added tests for set_point and scrape all
riley206 Oct 2, 2023
2e42775
Updates for tests run on Docker before 9.0 release.
davidraker Oct 2, 2023
f23038b
Added tests for home assistant driver
riley206 Oct 2, 2023
4d116db
Implemented get_point
riley206 Oct 2, 2023
b58956d
Corrected XFail mark in modbus_tk/tests/test_battery_meter.py.
davidraker Oct 3, 2023
9bee2a6
fixed typo
riley206 Oct 4, 2023
aa80df5
fixed typo
riley206 Oct 4, 2023
94a9f11
update for issue 3124
schandrika Oct 4, 2023
2abeeb1
Update for issue 3124
schandrika Oct 4, 2023
398063f
Added Error checking for lights
riley206 Oct 6, 2023
79f8e08
Added configuration variable checks
riley206 Oct 6, 2023
e0ead39
Added better error checking and ValueErrors for brightness
riley206 Oct 6, 2023
de30824
fixed typo
riley206 Oct 6, 2023
0749c5e
More error checking
riley206 Oct 6, 2023
d701260
even more error checking
riley206 Oct 6, 2023
e001131
More more error checking
riley206 Oct 6, 2023
58c76ea
info for single config entry for multiple devices
schandrika Oct 9, 2023
be1d755
Made reference image locally accessible
riley206 Oct 9, 2023
1aefb54
fixed reference to image
schandrika Oct 9, 2023
71a3979
info for single config entry for multiple devices
schandrika Oct 9, 2023
37d1086
documentation updates to support sequence diagram generation using me…
schandrika Oct 9, 2023
5cd4bee
minor cleanup
schandrika Oct 9, 2023
fa2e03a
minor extension error fix
schandrika Oct 9, 2023
1408db3
pep8 clean up
schandrika Oct 9, 2023
37c3671
raising exception instead of only logging
schandrika Oct 9, 2023
95eb4d9
minor pep8 cleanup
schandrika Oct 9, 2023
d88f847
refactored post operation into a method - avoids code repetition and …
schandrika Oct 9, 2023
81615fd
Merge remote-tracking branch 'origin/home_assitant' into home_assitant
schandrika Oct 9, 2023
8472916
Merge pull request #2 from schandrika/home_assitant
riley206 Oct 10, 2023
dca5bd0
Allow for any attribute name
riley206 Oct 10, 2023
94fcd33
Added entity_point to allow for control of volttron point name
riley206 Oct 10, 2023
b52d68a
Adjusted test_home_assistant to match new registry
riley206 Oct 10, 2023
808ee2c
minor adjustments
riley206 Oct 10, 2023
147d22a
Updated readme to match
riley206 Oct 10, 2023
4fb6a26
minor text changes
schandrika Oct 11, 2023
db1275a
Merge pull request #3122 from davidraker/docker_test_updates
shwethanidd Oct 12, 2023
d06b3e1
Updated EnergyPlusAgent to support the configuration file layout of b…
davidraker Oct 17, 2023
822e2ae
Corrected assignment to object variable on wrong class.
davidraker Oct 17, 2023
ab32fd2
Updated yml config to match location of files in json config.
davidraker Oct 17, 2023
089c53a
Merge pull request #3089 from riley206/main
craig8 Oct 18, 2023
841bb4e
Merge pull request #3123 from davidraker/boolean_registers
craig8 Oct 18, 2023
f0271c7
Merge pull request #3126 from davidraker/eplus_fix
craig8 Oct 18, 2023
de5cf74
revivied Craig s code to resolved the issue that uuid has extra chars…
kefeimo Oct 20, 2023
8a513f0
optimized _calc_min_uuid_length(agents)
kefeimo Oct 20, 2023
36c67e9
updates to support multiple metadata files and or directory as input …
schandrika Oct 22, 2023
638ad48
updated help text formatting
schandrika Oct 23, 2023
ef7a953
tests for vcfg update-config-store
schandrika Oct 23, 2023
bce93fe
Updated help text and vcfg documentation
schandrika Oct 23, 2023
26e9b77
minor pep 8 fixes
schandrika Oct 23, 2023
5d96abe
Merge pull request #3129 from kefeimo/hot-fix/uuid-having-extr-chars
craig8 Oct 23, 2023
96af525
Merge pull request #3131 from schandrika/config_bulk_update
schandrika Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ You can deactivate the environment at any time by running `deactivate`.
###### Install Erlang pre-requisites
```shell
sudo apt-get update
sudo apt-get install -y gnupg apt-transport-https libsctp1
sudo apt-get install -y gnupg apt-transport-https libsctp1 libncurses5
```
Please note there could be other pre-requisites that erlang requires based on the version of Erlang and OS. If there are other pre-requisites required,
install of erlang should fail with appropriate error message.

###### Purge previous versions of Erlang
```shell
Expand Down
8 changes: 4 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sphinx_rtd_theme
sphinx-autobuild
sphinx==3.3.0
m2r2
sphinx==5.1.1
sphinx-rtd-theme==1.0.0
m2r2==0.3.2
sphinxcontrib-mermaid
bacpypes
enum34
funcsigs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,4 @@ To view data being published from the fake driver on the message bus, one can
modbus/modbus-tk-driver
obix/obix
ted-driver/the-energy-detective-driver
home-assistant/HomeAssistantDriver
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
.. _HomeAssistant-Driver:

Home Assistant Driver
=====================

The Home Assistant driver enables VOLTTRON to read any data point from any Home Assistant controlled device.
Currently control(write access) is supported only for lights(state and brightness) and thermostats(state and temperature).

The following diagram shows interaction between platform driver agent and home assistant driver.

.. mermaid::

sequenceDiagram
HomeAssistant Driver->>HomeAssistant: Retrieve Entity Data (REST API)
HomeAssistant-->>HomeAssistant Driver: Entity Data (Status Code: 200)
HomeAssistant Driver->>PlatformDriverAgent: Publish Entity Data
PlatformDriverAgent->>Controller Agent: Publish Entity Data

Controller Agent->>HomeAssistant Driver: Instruct to Turn Off Light
HomeAssistant Driver->>HomeAssistant: Send Turn Off Light Command (REST API)
HomeAssistant-->>HomeAssistant Driver: Command Acknowledgement (Status Code: 200)

Pre-requisites
--------------
Before proceeding, find your Home Assistant IP address and long-lived access token from `here <https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token>`_.

Clone the repository, start volttron, install the listener agent, and the platform driver agent.

- `Listener agent <https://volttron.readthedocs.io/en/main/introduction/platform-install.html#installing-and-running-agents>`_
- `Platform driver agent <https://volttron.readthedocs.io/en/main/agent-framework/core-service-agents/platform-driver/platform-driver-agent.html?highlight=platform%20driver%20isntall#configuring-the-platform-driver>`_

Configuration
--------------

After cloning, generate configuration files. Each device requires one device configuration file and one registry file.
Ensure your registry_config parameter in your device configuration file, links to correct registry config name in the
config store. For more details on how volttron platform driver agent works with volttron configuration store see,
`Platform driver configuration <https://volttron.readthedocs.io/en/main/agent-framework/driver-framework/platform-driver/platform-driver.html#configuration-and-installation>`_
Examples for lights and thermostats are provided below.

Device configuration
++++++++++++++++++++

Device configuration file contains the connection details to you home assistant instance and driver_type as "home_assistant"

.. code-block:: json

{
"driver_config": {
"ip_address": "Your Home Assistant IP",
"access_token": "Your Home Assistant Access Token",
"port": "Your Port"
},
"driver_type": "home_assistant",
"registry_config": "config://light.example.json",
"interval": 30,
"timezone": "UTC"
}

Registry Configuration
+++++++++++++++++++++++

Registry file can contain one single device and its attributes or a logical group of devices and its
attributes. Each entry should include the full entity id of the device, including but not limited to home assistant provided prefix
such as "light.", "climate." etc. The driver uses these prefixes to convert states into integers.
Like mentioned before, the driver can only control lights and thermostats but can get data from all devices
controlled by home assistant

Each entry in a registry file should also have a 'Entity Point' and a unique value for 'Volttron Point Name'. The 'Entity ID' maps to the device instance, the 'Entity Point' extracts the attribute or state, and 'Volttron Point Name' determines the name of that point as it appears in VOLTTRON.

Attributes can be located in the developer tools in the Home Assistant GUI.

.. image:: home-assistant.png


Below is an example file named light.example.json which has attributes of a single light instance with entity
id 'light.example':


.. code-block:: json

[
{
"Entity ID": "light.example",
"Entity Point": "state",
"Volttron Point Name": "light_state",
"Units": "On / Off",
"Units Details": "on/off",
"Writable": true,
"Starting Value": true,
"Type": "boolean",
"Notes": "lights hallway"
},
{
"Entity ID": "light.example",
"Entity Point": "brightness",
"Volttron Point Name": "light_brightness",
"Units": "int",
"Units Details": "light level",
"Writable": true,
"Starting Value": 0,
"Type": "int",
"Notes": "brightness control, 0 - 255"
}
]


.. note::

When using a single registry file to represent a logical group of multiple physical entities, make sure the
"Volttron Point Name" is unique within a single registry file.

For example, if a registry file contains entities with
id 'light.instance1' and 'light.instance2' the entry for the attribute brightness for these two light instances could
have "Volttron Point Name" as 'light1/brightness' and 'light2/brightness' respectively. This would ensure that data
is posted to unique topic names and brightness data from light1 is not overwritten by light2 or vice-versa.

Example Thermostat Registry
***************************

For thermostats, the state is converted into numbers as follows: "0: Off, 2: heat, 3: Cool, 4: Auto",

.. code-block:: json

[
{
"Entity ID": "climate.my_thermostat",
"Entity Point": "state",
"Volttron Point Name": "thermostat_state",
"Units": "Enumeration",
"Units Details": "0: Off, 2: heat, 3: Cool, 4: Auto",
"Writable": true,
"Starting Value": 1,
"Type": "int",
"Notes": "Mode of the thermostat"
},
{
"Entity ID": "climate.my_thermostat",
"Entity Point": "current_temperature",
"Volttron Point Name": "volttron_current_temperature",
"Units": "F",
"Units Details": "Current Ambient Temperature",
"Writable": true,
"Starting Value": 72,
"Type": "float",
"Notes": "Current temperature reading"
},
{
"Entity ID": "climate.my_thermostat",
"Entity Point": "temperature",
"Volttron Point Name": "set_temperature",
"Units": "F",
"Units Details": "Desired Temperature",
"Writable": true,
"Starting Value": 75,
"Type": "float",
"Notes": "Target Temp"
}
]



Transfer the registers files and the config files into the VOLTTRON config store using the commands below:

.. code-block:: bash

vctl config store platform.driver light.example.json HomeAssistant_Driver/light.example.json
vctl config store platform.driver devices/BUILDING/ROOM/light.example HomeAssistant_Driver/light.example.config

Upon completion, initiate the platform driver. Utilize the listener agent to verify the driver output:

.. code-block:: bash

2023-09-12 11:37:00,226 (listeneragent-3.3 211531) __main__ INFO: Peer: pubsub, Sender: platform.driver:, Bus: , Topic: devices/BUILDING/ROOM/light.example/all, Headers: {'Date': '2023-09-12T18:37:00.224648+00:00', 'TimeStamp': '2023-09-12T18:37:00.224648+00:00', 'SynchronizedTimeStamp': '2023-09-12T18:37:00.000000+00:00', 'min_compatible_version': '3.0', 'max_compatible_version': ''}, Message:
[{'light_brightness': 254, 'state': 'on'},
{'light_brightness': {'type': 'integer', 'tz': 'UTC', 'units': 'int'},
'state': {'type': 'integer', 'tz': 'UTC', 'units': 'On / Off'}}]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def __getattr__(cls, name):
# http://www.sphinx-doc.org/en/master/usage/extensions/todo.html
'sphinx.ext.todo',
'sphinx.ext.intersphinx',
'm2r2'
'm2r2',
'sphinxcontrib.mermaid'
]

# prefix sections with the document so that we can cross link
Expand Down
60 changes: 52 additions & 8 deletions docs/source/deploying-volttron/platform-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Platform Configuration

Each instance of the VOLTTRON platform includes a `config` file which is used to configure the platform instance on
startup. This file is kept in :term:`VOLTTRON_HOME` and is created using the `volttron-cfg` (`vcfg`) command, or will
be created with default values on start up of the platform otherwise.
be created with default values on start up of the platform otherwise. `vcfg` also provides commands to configure and
install few frequently used agents and update configuration-store entries

Following is helpful information about the `config` file and the `vcfg` command.


VOLTTRON_HOME
=============

Expand Down Expand Up @@ -75,9 +75,13 @@ The example consists of the following entries:
VOLTTRON Config
===============

The `volttron-cfg` or `vcfg` command allows for an easy configuration of the VOLTTRON environment. The command includes
the ability to set up the platform configuration, an instance of the platform historian, VOLTTRON Central UI, and
VOLTTRON Central Platform agent.
The `volttron-cfg` or `vcfg` command allows for an easy configuration of the VOLTTRON environment.
The `vcfg` command can be run without any arguments to go through all available configuration steps sequentially and
pick what is appropriate for a given instance of VOLTTRON. This is useful when starting with a new VOLTTRON instance.

`vcfg` command can also be used with specific subcommands to configure and install specific agents such as
listener agent, platform historian, VOLTTRON Central UI, and VOLTTRON Central Platform agent
or add one or more agent configurations to VOLTTRON's configuration store.

Running `vcfg` will create a `config` file in `VOLTTRON_HOME` which will be populated according to the answers to
prompts. This process should be repeated for each platform instance, and can be re-run to reconfigure a platform
Expand Down Expand Up @@ -158,12 +162,52 @@ Optional Arguments
- **-v, --verbose** - Enables verbose output in standard-output (PIP output, etc.)
- **--vhome VHOME** - Provide a path to set `VOLTTRON_HOME` for this instance
- **--instance-name INSTANCE_NAME** - Provide a name for this instance. Required for running secure agents mode
- **--list-agents** - Display a list of configurable agents (Listener, Platform Driver, Platform Historian, VOLTTRON
Central, VOLTTRON Central Platform)
- **--agent AGENT [AGENT ...]** - Configure listed agents
- **--agent-isolation-mode** - Require that agents run as their own Unix users (this requires running
`scripts/secure_user_permissions.sh` as `sudo`)

Sub commands
------------
**--list-agents**
~~~~~~~~~~~~~~~~~~
Display a list of configurable agents (Listener, Platform Driver, Platform Historian, VOLTTRON
Central, VOLTTRON Central Platform)

**--agent AGENT [AGENT ...]**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Configure and install one of the listed agents for a specific VOLTTRON instance

**update-config-store --metadata-file METADATA_FILE_OR_DIR [METADATA_FILE_OR_DIR ...]**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Command to bulk add/update multiple agent configurations to VOLTTRON's configuration store. This is especially useful
for automated deployment use cases. For example, a automated deployment setup where devices in a network are
detected, and configurations for platform driver and control agents such as ILCAgent are auto generated using semantic
tags. In such as scenario, adding all the generated configurations to the configuration store using the below command
is more efficient than running the "vctl config store" command once for each configuration

This command can only be used when volttron instance is not running.

Usage:

.. code-block:: bash

vcfg update-config-store --metadata-file <one or more metadata file or directories containing metadata files separated by space>


Format for Metadata file:

.. code-block::

{ "vip-id": [
{
"config-name": "optional. name. defaults to config
"config": "json config or string config or config file name",
"config-type": "optional. type of config - csv or json or raw. defaults to json"
}, ...
],...
}


RabbitMQ Arguments
------------------
vcfg command to configure a single RabbitMQ instance of VOLTTRON.
Expand Down
4 changes: 3 additions & 1 deletion docs/source/introduction/platform-install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ Install Erlang pre-requisites
+++++++++++++++++++++++++++++
.. code-block:: bash
sudo apt-get update
sudo apt-get install -y gnupg apt-transport-https libsctp1
sudo apt-get install -y gnupg apt-transport-https libsctp1 libncurses5

Please note there could be other pre-requisites that erlang requires based on the version of Erlang and OS. If there are other pre-requisites required, install of erlang should fail with appropriate error message.

Purge previous versions of Erlang
+++++++++++++++++++++++++++++++++
Expand Down
12 changes: 6 additions & 6 deletions examples/EnergyPlusAgent/energyplus/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,22 @@ def check_advance(self):
timestep = int(60 / self.EnergyPlus_sim.timestep)

if not self.EnergyPlus_sim.real_time_flag:
self.cosim_sync_counter += timestep
if self.cosim_sync_counter < self.EnergyPlus_sim.co_sim_timestep:
self.EnergyPlus_sim.cosim_sync_counter += timestep
if self.EnergyPlus_sim.cosim_sync_counter < self.EnergyPlus_sim.co_sim_timestep:
self.advance_simulation(None, None, None, None, None, None)
else:
self.cosim_sync_counter = 0
self.EnergyPlus_sim.cosim_sync_counter = 0
self.vip.pubsub.publish('pubsub',
self.tns_actuate,
headers={},
message={}).get(timeout=10)
elif self.EnergyPlus_sim.hour > self.EnergyPlus_sim.currenthour or self.EnergyPlus_sim.passtime:
self.EnergyPlus_sim.passtime = True
self.cosim_sync_counter += timestep
if self.cosim_sync_counter < self.EnergyPlus_sim.co_sim_timestep:
self.EnergyPlus_sim.cosim_sync_counter += timestep
if self.EnergyPlus_sim.cosim_sync_counter < self.EnergyPlus_sim.co_sim_timestep:
self.advance_simulation(None, None, None, None, None, None)
else:
self.cosim_sync_counter = 0
self.EnergyPlus_sim.cosim_sync_counter = 0
self.vip.pubsub.publish('pubsub',
self.tns_actuate,
headers={},
Expand Down
Loading
Loading