diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-18 07:47:28 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 07:47:28 +0000 |
| commit | 98c6acccf487a416404ce4997275e1fb46eba867 (patch) | |
| tree | dbda4b04fe09ff7ca03cdc5fe46abf25aec7ac2a | |
| parent | c6206f37df4ed751d34d5fc771045f9c6665671f (diff) | |
automatic import of python-pyduke-energy
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-pyduke-energy.spec | 572 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 574 insertions, 0 deletions
@@ -0,0 +1 @@ +/pyduke-energy-1.0.6.tar.gz diff --git a/python-pyduke-energy.spec b/python-pyduke-energy.spec new file mode 100644 index 0000000..e809eba --- /dev/null +++ b/python-pyduke-energy.spec @@ -0,0 +1,572 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pyduke-energy +Version: 1.0.6 +Release: 1 +Summary: Python Wrapper for unofficial Duke Energy REST API +License: MIT License +URL: https://github.com/mjmeli/pyduke-energy +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/07/80/4574d62e7beb5a7f9c61e7e3d014b6420839ca4716d83de51ebf3a817fb1/pyduke-energy-1.0.6.tar.gz +BuildArch: noarch + +Requires: python3-aiohttp +Requires: python3-dateutil +Requires: python3-paho-mqtt +Requires: python3-jsonpickle +Requires: python3-kafka-python +Requires: python3-build +Requires: python3-twine +Requires: python3-tox +Requires: python3-pytest +Requires: python3-pytest-asyncio +Requires: python3-pytest-cov +Requires: python3-pytest-timeout +Requires: python3-black +Requires: python3-flake8 +Requires: python3-pylint +Requires: python3-pydocstyle +Requires: python3-isort + +%description +# pyDuke-Energy + +[![PyPi Project][pypi-shield]][pypi] +[![GitHub Build][build-shield]][build] +[![GitHub Activity][commits-shield]][commits] +[![License][license-shield]](LICENSE) + +[![Project Maintenance][maintenance-shield]][user_profile] +[![GitHub Top Language][language-shield]][language] +[![Black][black-shield]][black] + +Python3 wrapper for the unofficial Duke Energy API. + +Designed to work with Home Assistant. Unlikely to ever be fully implemented. The primary goal is to expose Duke Energy Gateway usage information. + +The library supports access to the real-time power usage implemented via an MQTT over websockets connection, or a more traditional REST API to poll near-real-time data. + +## IMPORTANT - Deprecation Warning + +**Duke Energy is shutting down the Gateway pilot program at the end of June. This library will stop functioning and will be deprecated.** + +## Before You Begin + +### Disclaimer + +The API is unofficial, not documented, and probably not supposed to be used by third-parties. It is only accessible as it powers the Duke Energy phone app and we can mimic the app requests. + +In addition, the Gateway functionality is part of a pilot program. There is no guarantee on availability going forward. + +With that said, please see this disclaimer: **This library could stop working at any time. Some functionality may be removed from the API entirely. Duke Energy may even request we stop hitting this API.** + +Along those same lines, **please do not abuse their API**. + +### Gateway Requirement + +In order to call the gateway related functions, including getting energy usage, you will need to have a Duke Energy Gateway. This is currently available via a pilot program. + +It is possible to query _yesterday's_ energy usage without a gateway; however, I have not implemented that as I did not find it useful. + +### Limitations + +Some limitations I've identified: + +- Non-real-time Energy usage data is down to the minute, but is only updated once every 15 minutes. Meaning, the last 15 minutes of minute-by-minute data will all arrive at once after 15 minutes. My best guess is that the gateway only sends data to Duke Energy every 15 minutes. This is a limitation in the app as well. + +## Usage + +### Installation + +The latest version is available on PyPi. + +```bash +pip install pyduke-energy +``` + +### Examples + +Various usage examples can be found in the `examples/` folder of this repo. + +#### Example REST API Usage + +The quick example below shows how to retrieve non-real-time usage info using the traditional REST API. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + await duke_energy.select_default_meter() # NB: can also use MeterInfo from API with select_meter() + usage = await duke_energy.get_gateway_usage(datetime.date(2021, 1, 1), datetime.date(2021, 1, 2)) +``` + +A more detailed example is in [examples/example_rest.py](examples/example_rest.py). + +#### Example Real-time Usage + +Real-time usage can be retrieved using an MQTT connection. The quick example below shows how to do this using the default real-time client. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + duke_rt = DukeEnergyRealtime(duke_energy) + await duke_rt.select_default_meter() + await duke_rt.connect_and_subscribe_forever() +``` + +More detailed examples can be found in [examples/example_realtime.py](examples/example_realtime.py) and [examples/example_realtime_kafka.py](examples/example_realtime_kafka.py). + +#### Running Examples + +If you want to run the examples, you will need to install extra dependencies. + +```bash +pip install .[example] +python examples/example_rest.py +``` + +## Development + +### Environment Setup + +#### Dev Container + +The preferred method of development is using the Visual Studio Code devcontainer, which will handle setting up your environment including all dependencies. + +1. Open repo in VS Code (e.g. `code .` from repo root) +2. Re-open in container when the pop-up appears in VS Code +3. Wait for the container to build +4. Done! + +#### Manual Installation + +You can also develop outside of a dev container if desired. The example below uses a `virtualenv` which is optional but recommended. + +```bash +virtualenv venv +source venv/bin/activate +pip install -e .[example,tests] +``` + +### Testing + +The test command will run the test suite and also run linting against all source files. + +```bash +tox +``` + +To run just the tests: + +```bash +tox -e py310 +``` + +To run just the linting: + +```bash +tox -e lint +``` + +### Android App Debugging + +If you want to debug requests via the Android app, the following general approach works well for me. + +1. Install [HTTP Toolkit](https://httptoolkit.tech/) on your computer. +2. Set up Android Studio so that you can use an emulator through it. +3. Start Android Studio emulator and use HTTP Toolkit to connect to it via ADB. Make sure to set up the HTTPS request intercepting. +4. Install Duke Energy APK on the emulator. You can download an `xapk` file from a site like APKPure. To install an `xapk` file on an emulator, extract the `xapk` file using something like WinRAR and drag the inside `apk` file to the emulator. +5. Start Duke Energy app on the emulator and logs should now be requested in your HTTP Toolkit app. + +[black]: https://github.com/psf/black +[black-shield]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge +[commits-shield]: https://img.shields.io/github/commit-activity/y/mjmeli/pyduke-energy.svg?style=for-the-badge +[commits]: https://github.com/mjmeli/pyduke-energy/commits/main +[license-shield]: https://img.shields.io/github/license/mjmeli/pyduke-energy.svg?style=for-the-badge +[maintenance-shield]: https://img.shields.io/badge/maintainer-%40mjmeli-blue.svg?style=for-the-badge +[pypi-shield]: https://img.shields.io/pypi/v/pyduke-energy?style=for-the-badge +[pypi]: https://pypi.org/project/pyduke-energy/ +[build-shield]: https://img.shields.io/github/actions/workflow/status/mjmeli/pyduke-energy/tests.yml?branch=main&style=for-the-badge +[build]: https://github.com/mjmeli/pyduke-energy/actions/workflows/tests.yaml +[language-shield]: https://img.shields.io/github/languages/top/mjmeli/pyduke-energy?style=for-the-badge +[language]: https://github.com/mjmeli/ha-duke-energy-gateway/search?l=python +[user_profile]: https://github.com/mjmeli + + +%package -n python3-pyduke-energy +Summary: Python Wrapper for unofficial Duke Energy REST API +Provides: python-pyduke-energy +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pyduke-energy +# pyDuke-Energy + +[![PyPi Project][pypi-shield]][pypi] +[![GitHub Build][build-shield]][build] +[![GitHub Activity][commits-shield]][commits] +[![License][license-shield]](LICENSE) + +[![Project Maintenance][maintenance-shield]][user_profile] +[![GitHub Top Language][language-shield]][language] +[![Black][black-shield]][black] + +Python3 wrapper for the unofficial Duke Energy API. + +Designed to work with Home Assistant. Unlikely to ever be fully implemented. The primary goal is to expose Duke Energy Gateway usage information. + +The library supports access to the real-time power usage implemented via an MQTT over websockets connection, or a more traditional REST API to poll near-real-time data. + +## IMPORTANT - Deprecation Warning + +**Duke Energy is shutting down the Gateway pilot program at the end of June. This library will stop functioning and will be deprecated.** + +## Before You Begin + +### Disclaimer + +The API is unofficial, not documented, and probably not supposed to be used by third-parties. It is only accessible as it powers the Duke Energy phone app and we can mimic the app requests. + +In addition, the Gateway functionality is part of a pilot program. There is no guarantee on availability going forward. + +With that said, please see this disclaimer: **This library could stop working at any time. Some functionality may be removed from the API entirely. Duke Energy may even request we stop hitting this API.** + +Along those same lines, **please do not abuse their API**. + +### Gateway Requirement + +In order to call the gateway related functions, including getting energy usage, you will need to have a Duke Energy Gateway. This is currently available via a pilot program. + +It is possible to query _yesterday's_ energy usage without a gateway; however, I have not implemented that as I did not find it useful. + +### Limitations + +Some limitations I've identified: + +- Non-real-time Energy usage data is down to the minute, but is only updated once every 15 minutes. Meaning, the last 15 minutes of minute-by-minute data will all arrive at once after 15 minutes. My best guess is that the gateway only sends data to Duke Energy every 15 minutes. This is a limitation in the app as well. + +## Usage + +### Installation + +The latest version is available on PyPi. + +```bash +pip install pyduke-energy +``` + +### Examples + +Various usage examples can be found in the `examples/` folder of this repo. + +#### Example REST API Usage + +The quick example below shows how to retrieve non-real-time usage info using the traditional REST API. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + await duke_energy.select_default_meter() # NB: can also use MeterInfo from API with select_meter() + usage = await duke_energy.get_gateway_usage(datetime.date(2021, 1, 1), datetime.date(2021, 1, 2)) +``` + +A more detailed example is in [examples/example_rest.py](examples/example_rest.py). + +#### Example Real-time Usage + +Real-time usage can be retrieved using an MQTT connection. The quick example below shows how to do this using the default real-time client. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + duke_rt = DukeEnergyRealtime(duke_energy) + await duke_rt.select_default_meter() + await duke_rt.connect_and_subscribe_forever() +``` + +More detailed examples can be found in [examples/example_realtime.py](examples/example_realtime.py) and [examples/example_realtime_kafka.py](examples/example_realtime_kafka.py). + +#### Running Examples + +If you want to run the examples, you will need to install extra dependencies. + +```bash +pip install .[example] +python examples/example_rest.py +``` + +## Development + +### Environment Setup + +#### Dev Container + +The preferred method of development is using the Visual Studio Code devcontainer, which will handle setting up your environment including all dependencies. + +1. Open repo in VS Code (e.g. `code .` from repo root) +2. Re-open in container when the pop-up appears in VS Code +3. Wait for the container to build +4. Done! + +#### Manual Installation + +You can also develop outside of a dev container if desired. The example below uses a `virtualenv` which is optional but recommended. + +```bash +virtualenv venv +source venv/bin/activate +pip install -e .[example,tests] +``` + +### Testing + +The test command will run the test suite and also run linting against all source files. + +```bash +tox +``` + +To run just the tests: + +```bash +tox -e py310 +``` + +To run just the linting: + +```bash +tox -e lint +``` + +### Android App Debugging + +If you want to debug requests via the Android app, the following general approach works well for me. + +1. Install [HTTP Toolkit](https://httptoolkit.tech/) on your computer. +2. Set up Android Studio so that you can use an emulator through it. +3. Start Android Studio emulator and use HTTP Toolkit to connect to it via ADB. Make sure to set up the HTTPS request intercepting. +4. Install Duke Energy APK on the emulator. You can download an `xapk` file from a site like APKPure. To install an `xapk` file on an emulator, extract the `xapk` file using something like WinRAR and drag the inside `apk` file to the emulator. +5. Start Duke Energy app on the emulator and logs should now be requested in your HTTP Toolkit app. + +[black]: https://github.com/psf/black +[black-shield]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge +[commits-shield]: https://img.shields.io/github/commit-activity/y/mjmeli/pyduke-energy.svg?style=for-the-badge +[commits]: https://github.com/mjmeli/pyduke-energy/commits/main +[license-shield]: https://img.shields.io/github/license/mjmeli/pyduke-energy.svg?style=for-the-badge +[maintenance-shield]: https://img.shields.io/badge/maintainer-%40mjmeli-blue.svg?style=for-the-badge +[pypi-shield]: https://img.shields.io/pypi/v/pyduke-energy?style=for-the-badge +[pypi]: https://pypi.org/project/pyduke-energy/ +[build-shield]: https://img.shields.io/github/actions/workflow/status/mjmeli/pyduke-energy/tests.yml?branch=main&style=for-the-badge +[build]: https://github.com/mjmeli/pyduke-energy/actions/workflows/tests.yaml +[language-shield]: https://img.shields.io/github/languages/top/mjmeli/pyduke-energy?style=for-the-badge +[language]: https://github.com/mjmeli/ha-duke-energy-gateway/search?l=python +[user_profile]: https://github.com/mjmeli + + +%package help +Summary: Development documents and examples for pyduke-energy +Provides: python3-pyduke-energy-doc +%description help +# pyDuke-Energy + +[![PyPi Project][pypi-shield]][pypi] +[![GitHub Build][build-shield]][build] +[![GitHub Activity][commits-shield]][commits] +[![License][license-shield]](LICENSE) + +[![Project Maintenance][maintenance-shield]][user_profile] +[![GitHub Top Language][language-shield]][language] +[![Black][black-shield]][black] + +Python3 wrapper for the unofficial Duke Energy API. + +Designed to work with Home Assistant. Unlikely to ever be fully implemented. The primary goal is to expose Duke Energy Gateway usage information. + +The library supports access to the real-time power usage implemented via an MQTT over websockets connection, or a more traditional REST API to poll near-real-time data. + +## IMPORTANT - Deprecation Warning + +**Duke Energy is shutting down the Gateway pilot program at the end of June. This library will stop functioning and will be deprecated.** + +## Before You Begin + +### Disclaimer + +The API is unofficial, not documented, and probably not supposed to be used by third-parties. It is only accessible as it powers the Duke Energy phone app and we can mimic the app requests. + +In addition, the Gateway functionality is part of a pilot program. There is no guarantee on availability going forward. + +With that said, please see this disclaimer: **This library could stop working at any time. Some functionality may be removed from the API entirely. Duke Energy may even request we stop hitting this API.** + +Along those same lines, **please do not abuse their API**. + +### Gateway Requirement + +In order to call the gateway related functions, including getting energy usage, you will need to have a Duke Energy Gateway. This is currently available via a pilot program. + +It is possible to query _yesterday's_ energy usage without a gateway; however, I have not implemented that as I did not find it useful. + +### Limitations + +Some limitations I've identified: + +- Non-real-time Energy usage data is down to the minute, but is only updated once every 15 minutes. Meaning, the last 15 minutes of minute-by-minute data will all arrive at once after 15 minutes. My best guess is that the gateway only sends data to Duke Energy every 15 minutes. This is a limitation in the app as well. + +## Usage + +### Installation + +The latest version is available on PyPi. + +```bash +pip install pyduke-energy +``` + +### Examples + +Various usage examples can be found in the `examples/` folder of this repo. + +#### Example REST API Usage + +The quick example below shows how to retrieve non-real-time usage info using the traditional REST API. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + await duke_energy.select_default_meter() # NB: can also use MeterInfo from API with select_meter() + usage = await duke_energy.get_gateway_usage(datetime.date(2021, 1, 1), datetime.date(2021, 1, 2)) +``` + +A more detailed example is in [examples/example_rest.py](examples/example_rest.py). + +#### Example Real-time Usage + +Real-time usage can be retrieved using an MQTT connection. The quick example below shows how to do this using the default real-time client. + +```python +async with aiohttp.ClientSession() as client: + duke_energy = DukeEnergyClient(email, password, client) + duke_rt = DukeEnergyRealtime(duke_energy) + await duke_rt.select_default_meter() + await duke_rt.connect_and_subscribe_forever() +``` + +More detailed examples can be found in [examples/example_realtime.py](examples/example_realtime.py) and [examples/example_realtime_kafka.py](examples/example_realtime_kafka.py). + +#### Running Examples + +If you want to run the examples, you will need to install extra dependencies. + +```bash +pip install .[example] +python examples/example_rest.py +``` + +## Development + +### Environment Setup + +#### Dev Container + +The preferred method of development is using the Visual Studio Code devcontainer, which will handle setting up your environment including all dependencies. + +1. Open repo in VS Code (e.g. `code .` from repo root) +2. Re-open in container when the pop-up appears in VS Code +3. Wait for the container to build +4. Done! + +#### Manual Installation + +You can also develop outside of a dev container if desired. The example below uses a `virtualenv` which is optional but recommended. + +```bash +virtualenv venv +source venv/bin/activate +pip install -e .[example,tests] +``` + +### Testing + +The test command will run the test suite and also run linting against all source files. + +```bash +tox +``` + +To run just the tests: + +```bash +tox -e py310 +``` + +To run just the linting: + +```bash +tox -e lint +``` + +### Android App Debugging + +If you want to debug requests via the Android app, the following general approach works well for me. + +1. Install [HTTP Toolkit](https://httptoolkit.tech/) on your computer. +2. Set up Android Studio so that you can use an emulator through it. +3. Start Android Studio emulator and use HTTP Toolkit to connect to it via ADB. Make sure to set up the HTTPS request intercepting. +4. Install Duke Energy APK on the emulator. You can download an `xapk` file from a site like APKPure. To install an `xapk` file on an emulator, extract the `xapk` file using something like WinRAR and drag the inside `apk` file to the emulator. +5. Start Duke Energy app on the emulator and logs should now be requested in your HTTP Toolkit app. + +[black]: https://github.com/psf/black +[black-shield]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge +[commits-shield]: https://img.shields.io/github/commit-activity/y/mjmeli/pyduke-energy.svg?style=for-the-badge +[commits]: https://github.com/mjmeli/pyduke-energy/commits/main +[license-shield]: https://img.shields.io/github/license/mjmeli/pyduke-energy.svg?style=for-the-badge +[maintenance-shield]: https://img.shields.io/badge/maintainer-%40mjmeli-blue.svg?style=for-the-badge +[pypi-shield]: https://img.shields.io/pypi/v/pyduke-energy?style=for-the-badge +[pypi]: https://pypi.org/project/pyduke-energy/ +[build-shield]: https://img.shields.io/github/actions/workflow/status/mjmeli/pyduke-energy/tests.yml?branch=main&style=for-the-badge +[build]: https://github.com/mjmeli/pyduke-energy/actions/workflows/tests.yaml +[language-shield]: https://img.shields.io/github/languages/top/mjmeli/pyduke-energy?style=for-the-badge +[language]: https://github.com/mjmeli/ha-duke-energy-gateway/search?l=python +[user_profile]: https://github.com/mjmeli + + +%prep +%autosetup -n pyduke-energy-1.0.6 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pyduke-energy -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.6-1 +- Package Spec generated @@ -0,0 +1 @@ +605ea1a0deece42c75a747c8c9b1c77e pyduke-energy-1.0.6.tar.gz |
