From 285ea1e835cd6118a6ec3855f2570eee40882c83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Dec 2022 23:06:01 +0000 Subject: [PATCH 01/11] Bump black from 22.8.0 to 22.12.0 Bumps [black](https://github.com/psf/black) from 22.8.0 to 22.12.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.8.0...22.12.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3690cda..98d81dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ test = pytest-asyncio>=0.18.3,<0.20.0 pytest-cov~=3.0.0 pytest-timeout~=2.1.0 - black==22.8.0 + black==22.12.0 flake8==5.0.4 pylint==2.15.0 pydocstyle==6.1.1 From 0f728d4a10a19b97b8114deee69f5b6fb6a0511f Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 13:50:23 -0500 Subject: [PATCH 02/11] fix build status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51dffd2..875d31e 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ If you want to debug requests via the Android app, the following general approac [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/workflow/status/mjmeli/pyduke-energy/Tests?style=for-the-badge +[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 From 643d2409e544af6d6703c3eef365fa6c95b61b0d Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 13:51:24 -0500 Subject: [PATCH 03/11] add twine install to release script --- release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/release.sh b/release.sh index 8adb67f..64b2b27 100644 --- a/release.sh +++ b/release.sh @@ -1,3 +1,4 @@ rm -rf dist +pip install twine python3 -m build python3 -m twine upload dist/* \ No newline at end of file From 78fc3c259ab596ee76807d885d82f472930171e0 Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 14:01:44 -0500 Subject: [PATCH 04/11] auto-approve dependabot prs --- .github/workflows/auto-approve.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/auto-approve.yml diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml new file mode 100644 index 0000000..2cd339b --- /dev/null +++ b/.github/workflows/auto-approve.yml @@ -0,0 +1,14 @@ +name: Auto approve + +on: pull_request_target + +jobs: + auto-approve: + runs-on: ubuntu-latest + permissions: + pull-requests: write + if: github.actor == 'dependabot[bot]' + steps: + - uses: hmarr/auto-approve-action@v3 + with: + review-message: "Auto approved automated PR" From 7484c8ca4cc02a6e311e04c08539b79f3d7398a6 Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 14:01:56 -0500 Subject: [PATCH 05/11] some supporting code file cleanup --- README.md | 2 +- release.sh | 2 +- setup.cfg | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 875d31e..fc693f9 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ If you want to run the examples, you will need to install extra dependencies. ```bash pip install .[example] -python example.py +python examples/example_rest.py ``` ## Development diff --git a/release.sh b/release.sh index 64b2b27..bdf689f 100644 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ rm -rf dist -pip install twine +pip install -e .[release] python3 -m build python3 -m twine upload dist/* \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 3690cda..3d6b149 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,8 @@ test = pylint==2.15.0 pydocstyle==6.1.1 isort~=5.10.1 +release = + twine [options.packages.find] where = src From f112d4b41f85d63c8182a0cc57242865f94c58af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 19:02:46 +0000 Subject: [PATCH 06/11] Bump pylint from 2.15.0 to 2.15.9 Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.0 to 2.15.9. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Commits](https://github.com/PyCQA/pylint/compare/v2.15.0...v2.15.9) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3d6b149..3d1097d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ test = pytest-timeout~=2.1.0 black==22.8.0 flake8==5.0.4 - pylint==2.15.0 + pylint==2.15.9 pydocstyle==6.1.1 isort~=5.10.1 release = From 7142a6259b2f557f3c1207ed6a3f995dfa6f266b Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 14:19:39 -0500 Subject: [PATCH 07/11] give up when MQTT fails to reconnect more than 10 times --- src/pyduke_energy/const.py | 9 ++++++++- src/pyduke_energy/realtime.py | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pyduke_energy/const.py b/src/pyduke_energy/const.py index 82166d7..e89bb64 100644 --- a/src/pyduke_energy/const.py +++ b/src/pyduke_energy/const.py @@ -5,13 +5,17 @@ IOT_API_BASE_URL = "https://app-core1.de-iot.io/rest/cloud/" FASTPOLL_ENDPOINT = "smartmeter/fastpoll/start" OAUTH_ENDPOINT = "auth/oauth2/token" -BASIC_AUTH = "Basic NEdtR3J1M085TEFIV3BMNjVjbWpyZDhtQ1VKZU5XTVo6OWFyZVZoZlM3R2N4UmgzWA==" # hard-coded from Android app SMARTMETER_AUTH_ENDPOINT = "smartmeter/v1/auth" ACCT_ENDPOINT = "auth/account-list" ACCT_DET_ENDPOINT = "auth/account-details" GW_STATUS_ENDPOINT = "gw/gateways/status" GW_USAGE_ENDPOINT = "smartmeter/usageByHour" +# hard-coded from Android app +BASIC_AUTH = ( + "Basic NEdtR3J1M085TEFIV3BMNjVjbWpyZDhtQ1VKZU5XTVo6OWFyZVZoZlM3R2N4UmgzWA==" +) + DEFAULT_TIMEOUT = 10 # seconds MQTT_HOST = "app-core1.de-iot.io" @@ -28,6 +32,9 @@ # number of times a message timeout can occur before just reconnecting MESSAGE_TIMEOUT_RETRY_COUNT = 3 +# number of times a message timeout can occur before we totally give up +MESSAGE_TIMEOUT_GIVE_UP_COUNT = 10 + # in minutes, minimum amount of time to wait before retrying connection on forever loop FOREVER_RETRY_MIN_MINUTES = 1 diff --git a/src/pyduke_energy/realtime.py b/src/pyduke_energy/realtime.py index b929018..05a42c1 100644 --- a/src/pyduke_energy/realtime.py +++ b/src/pyduke_energy/realtime.py @@ -17,6 +17,7 @@ FASTPOLL_TIMEOUT_SEC, FOREVER_RETRY_MAX_MINUTES, FOREVER_RETRY_MIN_MINUTES, + MESSAGE_TIMEOUT_GIVE_UP_COUNT, MESSAGE_TIMEOUT_RETRY_COUNT, MESSAGE_TIMEOUT_SEC, MQTT_ENDPOINT, @@ -291,13 +292,18 @@ async def connect_and_subscribe(self): await asyncio.wait_for(self._rx_msg, MESSAGE_TIMEOUT_SEC) self._msg_retry_count = 0 self._forever_retry_count = 0 - except asyncio.TimeoutError: + except asyncio.TimeoutError as toex: self._msg_retry_count += 1 if self._disconnected.done(): _LOGGER.debug( "Unexpected disconnect detected, attemping reconnect" ) await self._reconnect() + elif self._msg_retry_count > MESSAGE_TIMEOUT_GIVE_UP_COUNT: + _LOGGER.error("Too many msg timeouts, giving up") + raise MqttError( + "Reached timeout limit for reconnecting to MQTT" + ) from toex elif self._msg_retry_count > MESSAGE_TIMEOUT_RETRY_COUNT: _LOGGER.debug("Multiple msg timeout, attempting reconnect") await self._reconnect() From f255bcfd45600af62090c82dd2293e31b7f1b0ae Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 14:28:41 -0500 Subject: [PATCH 08/11] autoapprove my own prs --- .github/workflows/auto-approve.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 2cd339b..c5e4ea6 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write - if: github.actor == 'dependabot[bot]' + if: github.actor == 'dependabot[bot]' || github.actor == 'mjmeli' steps: - uses: hmarr/auto-approve-action@v3 with: From ac16a34390e5443e92a1903a1c1cbd9e4106ed74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 19:30:50 +0000 Subject: [PATCH 09/11] Update pytest-cov requirement from ~=3.0.0 to >=3.0,<4.1 Updates the requirements on [pytest-cov](https://github.com/pytest-dev/pytest-cov) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest-cov/releases) - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v3.0.0...v4.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 377c24a..803bf48 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ test = tox pytest~=7.1.1 pytest-asyncio>=0.18.3,<0.20.0 - pytest-cov~=3.0.0 + pytest-cov>=3.0,<4.1 pytest-timeout~=2.1.0 black==22.12.0 flake8==5.0.4 From 47f0dc95e8e92fda55dfb2707f84e95be3d26fed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 19:30:53 +0000 Subject: [PATCH 10/11] Update pytest requirement from ~=7.1.1 to >=7.1.1,<7.3.0 Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/7.1.1...7.2.0) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 377c24a..011e97e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ example = kafka-python test = tox - pytest~=7.1.1 + pytest>=7.1.1,<7.3.0 pytest-asyncio>=0.18.3,<0.20.0 pytest-cov~=3.0.0 pytest-timeout~=2.1.0 From f5c33064d277f1c0b0d6995f117b8839ac059e94 Mon Sep 17 00:00:00 2001 From: Michael Meli Date: Fri, 6 Jan 2023 14:34:06 -0500 Subject: [PATCH 11/11] tick version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3d6b149..fc43f41 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = pyduke-energy -version = 1.0.2 +version = 1.0.3 author = Michael Meli author_email = mjmeli94@gmail.com description = Python Wrapper for unofficial Duke Energy REST API