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

Added SSL verification to Home Assistant driver #3153

Open
wants to merge 9 commits into
base: releases/9.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

# Run the specified tests and save the results to a unique file that can be archived for later analysis.
- name: Run pytest on ${{ matrix.python-version }}, ${{ matrix.os }}
uses: volttron/volttron-build-action@v7
uses: volttron/volttron-build-action@v6
with:
python_version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,44 @@ 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"
Device configuration file contains the connection details to you home assistant instance.

- **url**:
Replace ``[Your Home Assistant IP]`` and ``[Your Port]`` with your Home Assistant's IP address and port number, respectively, removing the brackets ``[]``. Ensure you specify the protocol (``http`` or ``https``) based on your setup. Refer to the `Home Assistant documentation <https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token>`_ for finding your IP address.

- **access_token**:
Substitute ``[Your Home Assistant Access Token]`` with your actual access token, again removing the brackets ``[]``. For instructions on obtaining your access token, visit `this guide <https://www.raycast.com/tonka3000/homeassistant>`_.

- **verify_ssl**:
Set to true to enable SSL certificate verification or false to bypass it. Default is true. Disabling verification may pose security risks.

- **ssl_cert_path**:
Enter the path to your SSL certificate if you are using a custom certificate for verification. Leave this field empty if you are not using a custom certificate. This field is empty by default.

.. 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"
}
{
"driver_config": {
"url": "http://[Your Home Assistant IP]:[Your Port]",
"access_token": "[Your Home Assistant Access Token]",
"verify_ssl": true,
"ssl_cert_path": ""
},
"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
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.
Expand Down Expand Up @@ -108,7 +121,7 @@ id 'light.example':
.. 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.
"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
Expand Down Expand Up @@ -174,13 +187,4 @@ Upon completion, initiate the platform driver. Utilize the listener agent to ver
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'}}]

Running Tests
+++++++++++++++++++++++
To run tests on the VOLTTRON home assistant driver you need to create a helper in your home assistant instance. This can be done by going to **Settings > Devices & services > Helpers > Create Helper > Toggle**. Name this new toggle **volttrontest**. After that run the pytest from the root of your VOLTTRON file.

.. code-block:: bash
pytest volttron/services/core/PlatformDriverAgent/tests/test_home_assistant.py

If everything works, you will see 6 passed tests.
'state': {'type': 'integer', 'tz': 'UTC', 'units': 'On / Off'}}]
13 changes: 0 additions & 13 deletions pyproject.toml

This file was deleted.

Loading
Loading