mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 18:38:03 +00:00
Use Device instead of SmartDevice where feasible (#1585)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
This commit is contained in:
@@ -4,7 +4,7 @@ import asyncio
|
|||||||
|
|
||||||
import asyncclick as click
|
import asyncclick as click
|
||||||
|
|
||||||
from kasa import DeviceType, Module, SmartDevice
|
from kasa import Device, DeviceType, Module
|
||||||
from kasa.smart import SmartChildDevice
|
from kasa.smart import SmartChildDevice
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
@@ -21,7 +21,7 @@ def pretty_category(cat: str):
|
|||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@pass_dev
|
@pass_dev
|
||||||
async def hub(dev: SmartDevice):
|
async def hub(dev: Device):
|
||||||
"""Commands controlling hub child device pairing."""
|
"""Commands controlling hub child device pairing."""
|
||||||
if dev.device_type is not DeviceType.Hub:
|
if dev.device_type is not DeviceType.Hub:
|
||||||
error(f"{dev} is not a hub.")
|
error(f"{dev} is not a hub.")
|
||||||
@@ -32,7 +32,7 @@ async def hub(dev: SmartDevice):
|
|||||||
|
|
||||||
@hub.command(name="list")
|
@hub.command(name="list")
|
||||||
@pass_dev
|
@pass_dev
|
||||||
async def hub_list(dev: SmartDevice):
|
async def hub_list(dev: Device):
|
||||||
"""List hub paired child devices."""
|
"""List hub paired child devices."""
|
||||||
for c in dev.children:
|
for c in dev.children:
|
||||||
echo(f"{c.device_id}: {c}")
|
echo(f"{c.device_id}: {c}")
|
||||||
@@ -40,7 +40,7 @@ async def hub_list(dev: SmartDevice):
|
|||||||
|
|
||||||
@hub.command(name="supported")
|
@hub.command(name="supported")
|
||||||
@pass_dev
|
@pass_dev
|
||||||
async def hub_supported(dev: SmartDevice):
|
async def hub_supported(dev: Device):
|
||||||
"""List supported hub child device categories."""
|
"""List supported hub child device categories."""
|
||||||
cs = dev.modules[Module.ChildSetup]
|
cs = dev.modules[Module.ChildSetup]
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ async def hub_supported(dev: SmartDevice):
|
|||||||
@hub.command(name="pair")
|
@hub.command(name="pair")
|
||||||
@click.option("--timeout", default=10)
|
@click.option("--timeout", default=10)
|
||||||
@pass_dev
|
@pass_dev
|
||||||
async def hub_pair(dev: SmartDevice, timeout: int):
|
async def hub_pair(dev: Device, timeout: int):
|
||||||
"""Pair all pairable device.
|
"""Pair all pairable device.
|
||||||
|
|
||||||
This will pair any child devices currently in pairing mode.
|
This will pair any child devices currently in pairing mode.
|
||||||
|
@@ -190,7 +190,6 @@ AMBIENT_MODULE = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MOTION_MODULE = {
|
MOTION_MODULE = {
|
||||||
"get_adc_value": {"value": 50, "err_code": 0},
|
"get_adc_value": {"value": 50, "err_code": 0},
|
||||||
"get_config": {
|
"get_config": {
|
||||||
|
@@ -5,7 +5,7 @@ import logging
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from kasa import Feature, Module, SmartDevice
|
from kasa import Device, Feature, Module
|
||||||
|
|
||||||
from ...device_fixtures import parametrize
|
from ...device_fixtures import parametrize
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ childsetup = parametrize(
|
|||||||
|
|
||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_features(dev: SmartDevice):
|
async def test_childsetup_features(dev: Device):
|
||||||
"""Test the exposed features."""
|
"""Test the exposed features."""
|
||||||
cs = dev.modules.get(Module.ChildSetup)
|
cs = dev.modules.get(Module.ChildSetup)
|
||||||
assert cs
|
assert cs
|
||||||
@@ -27,7 +27,7 @@ async def test_childsetup_features(dev: SmartDevice):
|
|||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_pair(
|
async def test_childsetup_pair(
|
||||||
dev: SmartDevice, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
dev: Device, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
||||||
):
|
):
|
||||||
"""Test device pairing."""
|
"""Test device pairing."""
|
||||||
caplog.set_level(logging.INFO)
|
caplog.set_level(logging.INFO)
|
||||||
@@ -51,7 +51,7 @@ async def test_childsetup_pair(
|
|||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_unpair(
|
async def test_childsetup_unpair(
|
||||||
dev: SmartDevice, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
dev: Device, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
||||||
):
|
):
|
||||||
"""Test unpair."""
|
"""Test unpair."""
|
||||||
mock_query_helper = mocker.spy(dev, "_query_helper")
|
mock_query_helper = mocker.spy(dev, "_query_helper")
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from kasa import Module, SmartDevice
|
from kasa import Device, Module
|
||||||
|
|
||||||
from ...device_fixtures import get_parent_and_child_modules, parametrize
|
from ...device_fixtures import get_parent_and_child_modules, parametrize
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ async def test_features(dev, feature, prop_name, type):
|
|||||||
|
|
||||||
|
|
||||||
@powerprotection
|
@powerprotection
|
||||||
async def test_set_enable(dev: SmartDevice, mocker: MockerFixture):
|
async def test_set_enable(dev: Device, mocker: MockerFixture):
|
||||||
"""Test enable."""
|
"""Test enable."""
|
||||||
powerprot = next(get_parent_and_child_modules(dev, Module.PowerProtection))
|
powerprot = next(get_parent_and_child_modules(dev, Module.PowerProtection))
|
||||||
assert powerprot
|
assert powerprot
|
||||||
@@ -88,7 +88,7 @@ async def test_set_enable(dev: SmartDevice, mocker: MockerFixture):
|
|||||||
|
|
||||||
|
|
||||||
@powerprotection
|
@powerprotection
|
||||||
async def test_set_threshold(dev: SmartDevice, mocker: MockerFixture):
|
async def test_set_threshold(dev: Device, mocker: MockerFixture):
|
||||||
"""Test enable."""
|
"""Test enable."""
|
||||||
powerprot = next(get_parent_and_child_modules(dev, Module.PowerProtection))
|
powerprot = next(get_parent_and_child_modules(dev, Module.PowerProtection))
|
||||||
assert powerprot
|
assert powerprot
|
||||||
|
@@ -5,7 +5,7 @@ import logging
|
|||||||
import pytest
|
import pytest
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from kasa import Feature, Module, SmartDevice
|
from kasa import Device, Feature, Module
|
||||||
|
|
||||||
from ...device_fixtures import parametrize
|
from ...device_fixtures import parametrize
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ childsetup = parametrize(
|
|||||||
|
|
||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_features(dev: SmartDevice):
|
async def test_childsetup_features(dev: Device):
|
||||||
"""Test the exposed features."""
|
"""Test the exposed features."""
|
||||||
cs = dev.modules[Module.ChildSetup]
|
cs = dev.modules[Module.ChildSetup]
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ async def test_childsetup_features(dev: SmartDevice):
|
|||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_pair(
|
async def test_childsetup_pair(
|
||||||
dev: SmartDevice, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
dev: Device, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
||||||
):
|
):
|
||||||
"""Test device pairing."""
|
"""Test device pairing."""
|
||||||
caplog.set_level(logging.INFO)
|
caplog.set_level(logging.INFO)
|
||||||
@@ -69,7 +69,7 @@ async def test_childsetup_pair(
|
|||||||
|
|
||||||
@childsetup
|
@childsetup
|
||||||
async def test_childsetup_unpair(
|
async def test_childsetup_unpair(
|
||||||
dev: SmartDevice, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
dev: Device, mocker: MockerFixture, caplog: pytest.LogCaptureFixture
|
||||||
):
|
):
|
||||||
"""Test unpair."""
|
"""Test unpair."""
|
||||||
mock_query_helper = mocker.spy(dev, "_query_helper")
|
mock_query_helper = mocker.spy(dev, "_query_helper")
|
||||||
|
Reference in New Issue
Block a user