mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Remove SmartPlug in favor of SmartDevice (#781)
With the move towards autodetecting available features, there is no reason to keep SmartPlug around. kasa.smart.SmartPlug is removed in favor of kasa.smart.SmartDevice which offers the same functionality. Information about auto_off can be accessed using Features of the AutoOffModule on supported devices. Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,7 @@ from kasa import (
|
||||
)
|
||||
from kasa.iot import IotBulb, IotDimmer, IotLightStrip, IotPlug, IotStrip
|
||||
from kasa.protocol import BaseTransport
|
||||
from kasa.smart import SmartBulb, SmartPlug
|
||||
from kasa.smart import SmartBulb, SmartDevice
|
||||
from kasa.xortransport import XorEncryption
|
||||
|
||||
from .fakeprotocol_iot import FakeIotProtocol
|
||||
@@ -108,7 +108,6 @@ PLUGS_SMART = {
|
||||
"EP25",
|
||||
"KS205",
|
||||
"P125M",
|
||||
"P135",
|
||||
"S505",
|
||||
"TP15",
|
||||
}
|
||||
@@ -121,7 +120,7 @@ STRIPS_SMART = {"P300", "TP25"}
|
||||
STRIPS = {*STRIPS_IOT, *STRIPS_SMART}
|
||||
|
||||
DIMMERS_IOT = {"ES20M", "HS220", "KS220M", "KS230", "KP405"}
|
||||
DIMMERS_SMART = {"S500D"}
|
||||
DIMMERS_SMART = {"S500D", "P135"}
|
||||
DIMMERS = {
|
||||
*DIMMERS_IOT,
|
||||
*DIMMERS_SMART,
|
||||
@@ -346,7 +345,7 @@ def device_for_file(model, protocol):
|
||||
if protocol == "SMART":
|
||||
for d in PLUGS_SMART:
|
||||
if d in model:
|
||||
return SmartPlug
|
||||
return SmartDevice
|
||||
for d in BULBS_SMART:
|
||||
if d in model:
|
||||
return SmartBulb
|
||||
@@ -355,7 +354,7 @@ def device_for_file(model, protocol):
|
||||
return SmartBulb
|
||||
for d in STRIPS_SMART:
|
||||
if d in model:
|
||||
return SmartPlug
|
||||
return SmartDevice
|
||||
else:
|
||||
for d in STRIPS_IOT:
|
||||
if d in model:
|
||||
|
@@ -37,9 +37,6 @@ async def test_led(dev):
|
||||
@plug_smart
|
||||
async def test_plug_device_info(dev):
|
||||
assert dev._info is not None
|
||||
# PLUG_SCHEMA(dev.sys_info)
|
||||
|
||||
assert dev.model is not None
|
||||
|
||||
assert dev.device_type == DeviceType.Plug or dev.device_type == DeviceType.Strip
|
||||
# assert dev.is_plug or dev.is_strip
|
||||
|
@@ -22,16 +22,21 @@ from voluptuous import (
|
||||
|
||||
import kasa
|
||||
from kasa import Credentials, Device, DeviceConfig, KasaException
|
||||
from kasa.device_type import DeviceType
|
||||
from kasa.exceptions import SmartErrorCode
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.smart import SmartChildDevice, SmartDevice
|
||||
|
||||
from .conftest import (
|
||||
bulb,
|
||||
device_iot,
|
||||
device_smart,
|
||||
dimmer,
|
||||
handle_turn_on,
|
||||
has_emeter_iot,
|
||||
lightstrip,
|
||||
no_emeter_iot,
|
||||
plug,
|
||||
turn_on,
|
||||
)
|
||||
from .fakeprotocol_iot import FakeIotProtocol
|
||||
@@ -416,3 +421,25 @@ SYSINFO_SCHEMA = Schema(
|
||||
},
|
||||
extra=REMOVE_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
@dimmer
|
||||
def test_device_type_dimmer(dev):
|
||||
assert dev.device_type == DeviceType.Dimmer
|
||||
|
||||
|
||||
@bulb
|
||||
def test_device_type_bulb(dev):
|
||||
if dev.is_light_strip:
|
||||
pytest.skip("bulb has also lightstrips to test the api")
|
||||
assert dev.device_type == DeviceType.Bulb
|
||||
|
||||
|
||||
@plug
|
||||
def test_device_type_plug(dev):
|
||||
assert dev.device_type == DeviceType.Plug
|
||||
|
||||
|
||||
@lightstrip
|
||||
def test_device_type_lightstrip(dev):
|
||||
assert dev.device_type == DeviceType.LightStrip
|
||||
|
Reference in New Issue
Block a user