This is a custom integration for Home Assistant. It pulls real-time energy usage from Duke Energy via the Duke Energy Gateway pilot program.
This integration leverages the pyduke-energy library, also written by me, to pull data. This API is very unofficial and may stop working at any time (see Disclaimer). Also, you are required to have a Duke Energy Gateway connected to your smartmeter for this to work. This integration does not support any other method of retrieving data (see Gateway Requirement).
This component will set up the following entities:
- Represents the real-time power usage in watts.
- This data is pushed from the gateway device every 1-3 seconds. NOTE: This produces a lot of data. If this update interval is too frequent for you, you can configure a throttling interval in seconds (see Configuration below).
- Note that since this is power usage, it cannot be used as-is for the Home Assistant energy dashboard. Instead, you can use the
sensor.duke_energy_usage_today_kwhsensor, or you need to feed this real-time sensor through the Riemann sum integral integration. - Additional attributes are available containing the meter ID and gateway ID.
- Represents today's energy consumption in kilowatt-hours (from 0:00 local time to 23:59 local time, then resetting).
- This data is polled every 60 seconds, but data may be delayed up to 15 minutes due to delays in Duke Energy reporting it (see Limitations in the
pyduke-energyrepo.). - This can be used as-is for the Home Assistant energy consumption dashboard.
- Additional attributes are available containing the meter ID, gateway ID, and the timestamp of the last measurement.
- Add as a Custom Repository under Settings in HACS:
mjmeli/ha-duke-energy-gatewayand chooseIntegrationas the Category. - Restart Home Assistant
- In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Duke Energy Gateway"
- Using the tool of choice open the directory (folder) for your HA configuration (where you find
configuration.yaml). - If you do not have a
custom_componentsdirectory (folder) there, you need to create it. - In the
custom_componentsdirectory (folder) create a new folder calledduke_energy_gateway. - Download all the files from the
custom_components/duke_energy_gateway/directory (folder) in this repository. - Place the files you downloaded in the new directory (folder) you created.
- Restart Home Assistant
- In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Duke Energy Gateway"
Configuration will be done in the UI. Initially, you will need to provide the following data:
| Data | Description |
|---|---|
email |
Your login email to Duke Energy. |
password |
Your login password to Duke Energy. |
After the integration is setup, you will be able to do further configuration by clicking "Configure" on the integration page. This will allow you to modify the following options:
| Data | Description |
|---|---|
Real-time Usage Update Interval (sec) |
By default, the real-time usage sensor will be updated any time a reading comes in. If this data is too frequent, you can configure this value to throttle the data. When set to a positive integer X, the sensor will only be updated once every X seconds. In other words, if set to 30, you will get a new real-time usage every ~30 seconds. |
The configuration flow will automatically attempt to identify your gateway and smartmeter. Right now, only one is supported per account. The first one identified will be used. If one cannot be found, the configuration process should fail.
If your meter selection fails, a first step should be to enable logging for the component (see Logging). If this does not give insight into the problem, please open a GitHub issue.
If you run into any issues and want to look into the logs, this integration provides verbose logging at the debug level. That can be enabled by adding the following to your configuration.yaml file.
logger:
default: info
logs:
custom_components.duke_energy_gateway: debug
pyduke_energy.client: debug
pyduke_energy.realtime: debugI suggest using the dev container for development by opening in Visual Studio Code with code . and clicking on the option to re-open with dev container. In VS Code, you can run the task "Run Home Assistant on the port 9123" and then access it via http://localhost:9123.
If you want to install manually, you can install dev dependencies with pip install -r requirements_dev.txt.
Before commiting, run pre-commit run --all-files.
If you are working on implementing new changes from pyduke-energy but do not want to release version of that library, you can set up your development environment to install from a remote working branch.
- Update
requirements_dev.txtto replace themainingit+https://github.com/mjmeli/pyduke-energy@mainwith your working branch and update the username if you have a fork (e.g.git+https://github.com/notmjmeli/pyduke-energy@new-feature-dev-branch) - Uninstall locally cached version of
pyduke-energy:pip uninstall -y pyduke-energy - Re-run requirements installation:
pip install -r requirements_dev.txt
If you want to contribute to this please read the Contribution guidelines
This project was generated from @oncleben31's Home Assistant Custom Component Cookiecutter template.
Code template was mainly taken from @Ludeeus's integration_blueprint template