diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a7c571..d920974 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: env: CACHE_VERSION: 1 - DEFAULT_PYTHON: 3.8 + DEFAULT_PYTHON: 3.8.16 PRE_COMMIT_HOME: ~/.cache/pre-commit jobs: @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8.14', '3.9.15', '3.10.8', '3.11.0'] + python-version: ['3.8.16', '3.9.15', '3.10.8', '3.11.0'] steps: - name: Check out code from GitHub uses: actions/checkout@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b16775..f5bdfe2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.1.0 hooks: - id: black args: @@ -8,7 +8,7 @@ repos: - --quiet - repo: https://github.com/pycqa/flake8 - rev: 3.8.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: @@ -16,12 +16,12 @@ repos: - pydocstyle==5.1.1 - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/codespell-project/codespell - rev: v1.17.1 + rev: v2.2.4 hooks: - id: codespell args: diff --git a/setup.py b/setup.py index 3856070..5363f17 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,6 @@ author_email="schmidt.d@aon.at", license="GPL-3.0", packages=find_packages(exclude=["tests"]), - install_requires=["zigpy>=0.52.1"], + install_requires=["zigpy>=0.54.0"], tests_require=["pytest", "asynctest"], ) diff --git a/tests/test_application.py b/tests/test_application.py index e3c6267..d7ca6f6 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -2,11 +2,13 @@ import asyncio import logging +from unittest import mock import pytest +import zigpy.application import zigpy.config import zigpy.device -from zigpy.types import EUI64 +from zigpy.types import EUI64, Channels import zigpy.zdo.types as zdo_t from zigpy_deconz import types as t @@ -569,3 +571,16 @@ async def test_reset_network_info(app): await app.reset_network_info() app.form_network.assert_called_once() + + +async def test_energy_scan(app): + with mock.patch.object( + zigpy.application.ControllerApplication, + "energy_scan", + return_value={c: c for c in Channels.ALL_CHANNELS}, + ): + results = await app.energy_scan( + channels=Channels.ALL_CHANNELS, duration_exp=0, count=1 + ) + + assert results == {c: c * 3 for c in Channels.ALL_CHANNELS} diff --git a/zigpy_deconz/zigbee/application.py b/zigpy_deconz/zigbee/application.py index 9379b35..b4c7211 100644 --- a/zigpy_deconz/zigbee/application.py +++ b/zigpy_deconz/zigbee/application.py @@ -332,6 +332,16 @@ async def force_remove(self, dev): """Forcibly remove device from NCP.""" pass + async def energy_scan( + self, channels: t.Channels.ALL_CHANNELS, duration_exp: int, count: int + ) -> dict[int, float]: + results = await super().energy_scan( + channels=channels, duration_exp=duration_exp, count=count + ) + + # The Conbee seems to max out at an LQI of 85, which is exactly 255/3 + return {c: v * 3 for c, v in results.items()} + async def add_endpoint(self, descriptor: zdo_t.SimpleDescriptor) -> None: """Register an endpoint on the device, replacing any with conflicting IDs."""