From 0db9ab97d9f048eaa3dfd6d4ddfc1b5d2c35cc4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:22:32 +0000 Subject: [PATCH 01/14] Bump actions/setup-python from 4.7.0 to 4.7.1 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.0 to 4.7.1. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4.7.0...v4.7.1) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 105c759..03332eb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v4.7.0 + uses: actions/setup-python@v4.7.1 with: python-version: ${{ env.DEFAULT_PYTHON }} From 5c4a05ca63f43e2980b2985b0904711b8b4600c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:20:17 +0000 Subject: [PATCH 02/14] Bump reorder-python-imports from 3.11.0 to 3.12.0 in /.github/workflows Bumps [reorder-python-imports](https://github.com/asottile/reorder-python-imports) from 3.11.0 to 3.12.0. - [Commits](https://github.com/asottile/reorder-python-imports/compare/v3.11.0...v3.12.0) --- updated-dependencies: - dependency-name: reorder-python-imports dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 1e0e504..9732580 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -2,4 +2,4 @@ pip==23.2.1 pre-commit==3.4.0 black==23.9.1 flake8==6.1.0 -reorder-python-imports==3.11.0 +reorder-python-imports==3.12.0 From a99295763fc3f145a399ae363aa0d0ae0b78944e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:03:47 +0000 Subject: [PATCH 03/14] Bump pre-commit from 3.4.0 to 3.5.0 in /.github/workflows Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v3.4.0...v3.5.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 9732580..6130897 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -1,5 +1,5 @@ pip==23.2.1 -pre-commit==3.4.0 +pre-commit==3.5.0 black==23.9.1 flake8==6.1.0 reorder-python-imports==3.12.0 From a72a1d16844d28f0564712ad6640500c0497769a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:04:45 +0000 Subject: [PATCH 04/14] Bump pip from 23.2.1 to 23.3 in /.github/workflows Bumps [pip](https://github.com/pypa/pip) from 23.2.1 to 23.3. - [Changelog](https://github.com/pypa/pip/blob/main/NEWS.rst) - [Commits](https://github.com/pypa/pip/compare/23.2.1...23.3) --- updated-dependencies: - dependency-name: pip dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 6130897..2bbc050 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -1,4 +1,4 @@ -pip==23.2.1 +pip==23.3 pre-commit==3.5.0 black==23.9.1 flake8==6.1.0 From cc183a4d41fbbf28686fbcbfd72f2e5d2e488bd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:48:11 +0000 Subject: [PATCH 05/14] Bump release-drafter/release-drafter from 5.24.0 to 5.25.0 Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.24.0 to 5.25.0. - [Release notes](https://github.com/release-drafter/release-drafter/releases) - [Commits](https://github.com/release-drafter/release-drafter/compare/v5.24.0...v5.25.0) --- updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 49f39a9..f8d9503 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,6 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Run release-drafter - uses: release-drafter/release-drafter@v5.24.0 + uses: release-drafter/release-drafter@v5.25.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a267bd89fda1e82154d2d863d7904526b40b04b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:33:55 +0000 Subject: [PATCH 06/14] Bump black from 23.9.1 to 23.10.0 in /.github/workflows Bumps [black](https://github.com/psf/black) from 23.9.1 to 23.10.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/23.9.1...23.10.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/constraints.txt b/.github/workflows/constraints.txt index 2bbc050..e700dea 100644 --- a/.github/workflows/constraints.txt +++ b/.github/workflows/constraints.txt @@ -1,5 +1,5 @@ pip==23.3 pre-commit==3.5.0 -black==23.9.1 +black==23.10.0 flake8==6.1.0 reorder-python-imports==3.12.0 From 18ec937dd26a6be101eac33d3eee7348e3d7a266 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:47:28 -0700 Subject: [PATCH 07/14] Bump crazy-max/ghaction-github-labeler from 4.2.0 to 5.0.0 (#220) Bumps [crazy-max/ghaction-github-labeler](https://github.com/crazy-max/ghaction-github-labeler) from 4.2.0 to 5.0.0. - [Release notes](https://github.com/crazy-max/ghaction-github-labeler/releases) - [Commits](https://github.com/crazy-max/ghaction-github-labeler/compare/v4.2.0...v5.0.0) --- updated-dependencies: - dependency-name: crazy-max/ghaction-github-labeler dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 18ccb8d..0410562 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -15,6 +15,6 @@ jobs: uses: actions/checkout@v4 - name: Run Labeler - uses: crazy-max/ghaction-github-labeler@v4.2.0 + uses: crazy-max/ghaction-github-labeler@v5.0.0 with: skip-delete: true From 53963bd3a8bc011149b2d22c800e28d08da578a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Oct 2023 04:51:42 +0000 Subject: [PATCH 08/14] Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.5.1 to 1.6.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.5.1...v1.6.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/dependabot-auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index f807ee1..146d81f 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1.5.1 + uses: dependabot/fetch-metadata@v1.6.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Enable auto-merge for Dependabot PRs From fb60e4f1c1bb4c43003e0a78951877cca296b8ea Mon Sep 17 00:00:00 2001 From: Amos Yuen Date: Sat, 21 Oct 2023 06:31:22 +0000 Subject: [PATCH 09/14] Update dev env based on https://github.com/ludeeus/integration_blueprint --- .devcontainer/devcontainer.json | 52 +++++++++---------- .devcontainer/develop.sh | 20 +++++++ .devcontainer/setup.sh | 4 +- .github/dependabot.yml | 13 +++-- .gitignore | 16 ++++-- .ruff.toml | 48 +++++++++++++++++ .vscode/launch.json | 34 ------------ .vscode/settings.json | 17 +++--- .vscode/tasks.json | 22 +------- {.devcontainer => config}/configuration.yaml | 0 .../constraints.txt => requirements.txt | 7 ++- 11 files changed, 130 insertions(+), 103 deletions(-) create mode 100644 .devcontainer/develop.sh create mode 100644 .ruff.toml delete mode 100644 .vscode/launch.json rename {.devcontainer => config}/configuration.yaml (100%) rename .github/workflows/constraints.txt => requirements.txt (52%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ef68293..70416d5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,32 +1,30 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ghcr.io/ludeeus/devcontainer/integration:stable", "name": "TP-Link Deco integration development", - "context": "..", - "appPort": ["9123:8123"], - "postCreateCommand": ".devcontainer/setup.sh", - "mounts": [ - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/root/.gitconfig,type=bind,consistency=cached" - ], - "extensions": [ - "ms-python.python", - "github.vscode-pull-request-github", - "ryanluker.vscode-coverage-gutters", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode" - ], - "settings": { - "files.eol": "\n", - "editor.tabSize": 4, - "terminal.integrated.shell.linux": "/bin/bash", - "python.pythonPath": "/usr/bin/python3", - "python.analysis.autoSearchPaths": false, - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.formatting.provider": "black", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true + "image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye", + "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "postAttachCommand": ".devcontainer/setup.sh", + "forwardPorts": [8123], + "portsAttributes": { + "8123": { + "label": "Home Assistant", + "onAutoForward": "notify" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "esbenp.prettier-vscode", + "github.vscode-pull-request-github", + "ms-vscode-remote.remote-containers", + "ms-python.black-formatter", + "ms-python.vscode-pylance", + "ryanluker.vscode-coverage-gutters" + ] + } + }, + "remoteUser": "vscode", + "features": { + "ghcr.io/devcontainers/features/rust:1": {} } } diff --git a/.devcontainer/develop.sh b/.devcontainer/develop.sh new file mode 100644 index 0000000..89eda50 --- /dev/null +++ b/.devcontainer/develop.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +# Create config dir if not present +if [[ ! -d "${PWD}/config" ]]; then + mkdir -p "${PWD}/config" + hass --config "${PWD}/config" --script ensure_config +fi + +# Set the path to custom_components +## This let's us have the structure we want /custom_components/integration_blueprint +## while at the same time have Home Assistant configuration inside /config +## without resulting to symlinks. +export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components" + +# Start Home Assistant +hass --config "${PWD}/config" --debug diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 63ddc49..593d5bd 100644 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -6,7 +6,5 @@ set -e cd "$(dirname "$0")/.." -pip3 install -r .github/workflows/constraints.txt +pip3 install --requirement requirements.txt pre-commit install - -container install diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 15c7513..eee5550 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,12 +3,11 @@ updates: - package-ecosystem: github-actions directory: "/" schedule: - interval: daily - - package-ecosystem: pip - directory: "/.github/workflows" - schedule: - interval: daily - - package-ecosystem: pip + interval: weekly + - package-ecosystem: "pip" directory: "/" schedule: - interval: daily + interval: weekly + ignore: + # Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json + - dependency-name: "homeassistant" diff --git a/.gitignore b/.gitignore index a4a4d84..b66d45d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ +# artifacts __pycache__ -pythonenv* -.python-version +.pytest* +*.egg-info +*/build/* +*/dist/* + +# misc .coverage -venv -.venv +coverage.xml + +# Home Assistant configuration +config/* +!config/configuration.yaml diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..260b188 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,48 @@ +# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml + +target-version = "py310" + +select = [ + "B007", # Loop control variable {name} not used within loop body + "B014", # Exception handler with duplicate exception + "C", # complexity + "D", # docstrings + "E", # pycodestyle + "F", # pyflakes/autoflake + "ICN001", # import concentions; {name} should be imported as {asname} + "PGH004", # Use specific rule codes when using noqa + "PLC0414", # Useless import alias. Import alias does not rename original package. + "SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass + "SIM117", # Merge with-statements that use the same scope + "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() + "SIM201", # Use {left} != {right} instead of not {left} == {right} + "SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a} + "SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'. + "SIM401", # Use get from dict with default instead of an if block + "T20", # flake8-print + "TRY004", # Prefer TypeError exception for invalid type + "RUF006", # Store a reference to the return value of asyncio.create_task + "UP", # pyupgrade + "W", # pycodestyle +] + +ignore = [ + "D202", # No blank lines allowed after function docstring + "D203", # 1 blank line required before class docstring + "D213", # Multi-line docstring summary should start at the second line + "D404", # First word of the docstring should not be This + "D406", # Section name should end with a newline + "D407", # Section name underlining + "D411", # Missing blank line before section + "E501", # line too long + "E731", # do not assign a lambda expression, use a def +] + +[flake8-pytest-style] +fixture-parentheses = false + +[pyupgrade] +keep-runtime-typing = true + +[mccabe] +max-complexity = 25 diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index cc5337a..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - // Example of attaching to local debug server - "name": "Python: Attach Local", - "type": "python", - "request": "attach", - "port": 5678, - "host": "localhost", - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } - ] - }, - { - // Example of attaching to my production server - "name": "Python: Attach Remote", - "type": "python", - "request": "attach", - "port": 5678, - "host": "homeassistant.local", - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "/usr/src/homeassistant" - } - ] - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 2be6282..48bfb2f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,17 @@ { - "python.linting.pylintArgs": ["--rcfile=setup.cfg"], - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.pythonPath": "venv/bin/python", - "files.associations": { - "*.yaml": "home-assistant" + "analysis.autoSearchPaths": false, + "editor.codeActionsOnSave": { + "source.organizeImports": true }, + "editor.formatOnSave": true, + "editor.tabSize": 4, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "terminal.integrated.shell.linux": "/bin/bash", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index db41b54..46a87c8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,32 +2,14 @@ "version": "2.0.0", "tasks": [ { - "label": "Run Home Assistant on port 9123", + "label": "Run Home Assistant on port 8123", "type": "shell", - "command": "container start", + "command": ".devcontainer/develop.sh", "problemMatcher": [], "group": { "kind": "build", "isDefault": true } - }, - { - "label": "Run Home Assistant configuration against /config", - "type": "shell", - "command": "container check", - "problemMatcher": [] - }, - { - "label": "Upgrade Home Assistant to latest dev", - "type": "shell", - "command": "container install", - "problemMatcher": [] - }, - { - "label": "Install a specific version of Home Assistant", - "type": "shell", - "command": "container set-version", - "problemMatcher": [] } ] } diff --git a/.devcontainer/configuration.yaml b/config/configuration.yaml similarity index 100% rename from .devcontainer/configuration.yaml rename to config/configuration.yaml diff --git a/.github/workflows/constraints.txt b/requirements.txt similarity index 52% rename from .github/workflows/constraints.txt rename to requirements.txt index e700dea..a920ad7 100644 --- a/.github/workflows/constraints.txt +++ b/requirements.txt @@ -1,5 +1,8 @@ -pip==23.3 -pre-commit==3.5.0 black==23.10.0 +colorlog==6.7.0 flake8==6.1.0 +homeassistant==2023.6.0 +pip>=21.0,<23.2 +pre-commit==3.5.0 reorder-python-imports==3.12.0 +ruff==0.0.292 From 77225b26e098611c5c98b00184c0e20be058391b Mon Sep 17 00:00:00 2001 From: Amos Yuen Date: Sat, 21 Oct 2023 07:21:47 +0000 Subject: [PATCH 10/14] Fix options not getting updated when integration failed to initialize (#161) --- custom_components/tplink_deco/__init__.py | 21 ++++++------------- custom_components/tplink_deco/config_flow.py | 22 +++++++++++++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/custom_components/tplink_deco/__init__.py b/custom_components/tplink_deco/__init__.py index ec436b9..1627412 100644 --- a/custom_components/tplink_deco/__init__.py +++ b/custom_components/tplink_deco/__init__.py @@ -153,6 +153,8 @@ async def async_create_config_data(hass: HomeAssistant, config_entry: ConfigEntr async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry): """Set up this integration using UI.""" + _LOGGER.debug("async_setup_entry: Config entry %s", config_entry.entry_id) + if hass.data.get(DOMAIN) is None: hass.data.setdefault(DOMAIN, {}) @@ -194,11 +196,13 @@ async def async_reboot_deco(service: ServiceCall) -> None: ) config_entry.async_on_unload(config_entry.add_update_listener(update_listener)) + return True async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Handle removal of an entry.""" + _LOGGER.debug("async_unload_entry: Config entry %s", config_entry.entry_id) data = hass.data[DOMAIN][config_entry.entry_id] deco_coordinator = data.get(COORDINATOR_DECOS_KEY) clients_coordinator = data.get(COORDINATOR_CLIENTS_KEY) @@ -223,27 +227,14 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> async def async_reload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Reload config entry.""" + _LOGGER.debug("async_reload_entry: Config entry %s", config_entry) await async_unload_entry(hass, config_entry) await async_setup_entry(hass, config_entry) async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Update options.""" - if not config_entry.options or config_entry.data == config_entry.options: - _LOGGER.debug( - "update_listener: No changes in options for %s", config_entry.entry_id - ) - return - - _LOGGER.debug( - "update_listener: Updating options and reloading %s", config_entry.entry_id - ) - hass.config_entries.async_update_entry( - entry=config_entry, - title=config_entry.options.get(CONF_HOST), - data=config_entry.options, - options={}, - ) + _LOGGER.debug("update_listener: Reloading %s", config_entry.entry_id) await async_reload_entry(hass, config_entry) diff --git a/custom_components/tplink_deco/config_flow.py b/custom_components/tplink_deco/config_flow.py index 1082498..af69379 100644 --- a/custom_components/tplink_deco/config_flow.py +++ b/custom_components/tplink_deco/config_flow.py @@ -1,4 +1,5 @@ """Adds config flow for TP-Link Deco.""" +import asyncio import logging from typing import Any @@ -24,6 +25,8 @@ from .const import CONF_TIMEOUT_ERROR_RETRIES from .const import CONF_TIMEOUT_SECONDS from .const import CONF_VERIFY_SSL +from .const import COORDINATOR_CLIENTS_KEY +from .const import COORDINATOR_DECOS_KEY from .const import DEFAULT_CONSIDER_HOME from .const import DEFAULT_DECO_POSTFIX from .const import DEFAULT_SCAN_INTERVAL @@ -51,7 +54,7 @@ def _get_schema(data: dict[str:Any]): scan_interval = data.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL) schema.update( { - vol.Required(CONF_HOST, default=data.get(CONF_HOST, "192.168.0.1")): str, + vol.Required(CONF_HOST, default=data.get(CONF_HOST, "10.0.0.1")): str, vol.Required( CONF_SCAN_INTERVAL, default=scan_interval, @@ -112,7 +115,13 @@ def _ensure_user_input_optionals(data: dict[str:Any]) -> None: async def _async_test_credentials(hass: HomeAssistant, data: dict[str:Any]): """Return true if credentials is valid.""" try: - await async_create_and_refresh_coordinators(hass, data, consider_home_seconds=1) + coordinators = await async_create_and_refresh_coordinators( + hass, data, consider_home_seconds=1 + ) + await asyncio.gather( + coordinators[COORDINATOR_DECOS_KEY].async_shutdown(), + coordinators[COORDINATOR_CLIENTS_KEY].async_shutdown(), + ) return {} except TimeoutException: return {"base": "timeout_connect"} @@ -194,6 +203,7 @@ class TplinkDecoOptionsFlowHandler(config_entries.OptionsFlow): def __init__(self, config_entry: ConfigEntry): """Initialize HACS options flow.""" + self.config_entry = config_entry self.data = dict(config_entry.data) self._errors = {} @@ -207,7 +217,13 @@ async def async_step_init(self, user_input: dict[str:Any] = None): self._errors = await _async_test_credentials(self.hass, self.data) if len(self._errors) == 0: - return self.async_create_entry(data=self.data) + self.hass.config_entries.async_update_entry( + entry=self.config_entry, + title=self.data[CONF_HOST], + data=self.data, + options={}, + ) + return self.async_create_entry(data={}) return self.async_show_form( step_id="init", From 8ed16753156aea50e8e0e16e51882ce317aca4eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Oct 2023 07:29:01 +0000 Subject: [PATCH 11/14] Bump ruff from 0.0.292 to 0.1.1 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.292 to 0.1.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.292...v0.1.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a920ad7..4f79640 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ homeassistant==2023.6.0 pip>=21.0,<23.2 pre-commit==3.5.0 reorder-python-imports==3.12.0 -ruff==0.0.292 +ruff==0.1.1 From cdf25f93512eaf8d98bfd557439486c5a1439392 Mon Sep 17 00:00:00 2001 From: Amos Yuen Date: Sat, 21 Oct 2023 07:50:00 +0000 Subject: [PATCH 12/14] Fix workflow tests constraints file path --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 03332eb..1ea02e5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,12 +28,12 @@ jobs: - name: Upgrade pip run: | - pip install --constraint=.github/workflows/constraints.txt pip + pip install --constraint=requirements.txt pip pip --version - name: Install Python modules run: | - pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports + pip install --constraint=requirements.txt pre-commit black flake8 reorder-python-imports - name: Run pre-commit on all files run: | From b633a1102f3959d633ad38b9b958c995bfe46f1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:29:52 +0000 Subject: [PATCH 13/14] Bump black from 23.10.0 to 23.10.1 Bumps [black](https://github.com/psf/black) from 23.10.0 to 23.10.1. - [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/23.10.0...23.10.1) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4f79640..986a89f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -black==23.10.0 +black==23.10.1 colorlog==6.7.0 flake8==6.1.0 homeassistant==2023.6.0 From be97d1bb91290784f451d2647e22c1181b7ec022 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:30:05 +0000 Subject: [PATCH 14/14] Bump ruff from 0.1.1 to 0.1.3 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.1 to 0.1.3. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.1.1...v0.1.3) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4f79640..7c41d2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ homeassistant==2023.6.0 pip>=21.0,<23.2 pre-commit==3.5.0 reorder-python-imports==3.12.0 -ruff==0.1.1 +ruff==0.1.3