Skip to content

Add EP25 smart fixture and improve test framework for SMART devices #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ The following lists the devices that have been manually verified to work.
* KP105
* KP115
* KP125
* KP125M
* KP125M [See note below](#tapo-and-newer-kasa-branded-devices)
* KP401
* EP10
* EP25 [See note below](#tapo-and-newer-kasa-branded-devices)

### Power Strips

Expand Down Expand Up @@ -268,18 +269,25 @@ The following lists the devices that have been manually verified to work.

### Light strips

* KL400
* KL420
* KL400L5
* KL420L5
* KL430

### Tapo-branded devices
### Tapo and newer Kasa branded devices

The library has recently added a limited supported for devices that carry tapo branding.
The library has recently added a limited supported for devices that carry Tapo branding.

At the moment, the following devices have been confirmed to work:

* Tapo P110 (plug)
* Tapo L530 (bulb)
* Tapo L530E (bulb)

Some newer hardware versions of Kasa branded devices are now using the same protocol as
Tapo branded devices. Support for these devices is currently limited as per TAPO branded
devices:

* Kasa EP25 (plug) hw_version 2.6
* Kasa KP125M (plug)

**If your device is unlisted but working, please open a pull request to update the list and add a fixture file (use `devtools/dump_devinfo.py` to generate one).**

Expand All @@ -301,6 +309,12 @@ At the moment, the following devices have been confirmed to work:

### TP-Link Tapo support

This library has recently added a limited supported for devices that carry Tapo branding.
That support is currently limited to the cli. The package `kasa.tapo` is in flux and if you
use it directly you should expect it could break in future releases until this statement is removed.

Other TAPO libraries are:

* [PyTapo - Python library for communication with Tapo Cameras](https://github.com/JurajNyiri/pytapo)
* [Tapo P100 (Tapo P105/P100 plugs, Tapo L510E bulbs)](https://github.com/fishbigger/TapoP100)
* [Home Assistant integration](https://github.com/fishbigger/HomeAssistant-Tapo-P100-Control)
Expand Down
100 changes: 63 additions & 37 deletions kasa/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
SUPPORTED_DEVICES = SUPPORTED_IOT_DEVICES + SUPPORTED_SMART_DEVICES

# Tapo bulbs
BULBS_SMART_VARIABLE_TEMP = {"L530"}
BULBS_SMART_COLOR = {"L530"}
BULBS_SMART_VARIABLE_TEMP = {"L530E"}
BULBS_SMART_COLOR = {"L530E"}
BULBS_SMART_LIGHT_STRIP: Set[str] = set()
BULBS_SMART_DIMMABLE: Set[str] = set()
BULBS_SMART = (
Expand All @@ -54,7 +54,7 @@
)

# Kasa (IOT-prefixed) bulbs
BULBS_IOT_LIGHT_STRIP = {"KL400", "KL430", "KL420"}
BULBS_IOT_LIGHT_STRIP = {"KL400L5", "KL430", "KL420L5"}
BULBS_IOT_VARIABLE_TEMP = {
"LB120",
"LB130",
Expand Down Expand Up @@ -83,7 +83,7 @@
}


PLUGS = {
PLUGS_IOT = {
"HS100",
"HS103",
"HS105",
Expand All @@ -95,22 +95,35 @@
"KP105",
"KP115",
"KP125",
"KP125M",
"KP401",
"KS200M",
}
PLUGS_SMART = {"P110", "KP125M", "EP25"}
PLUGS = {
*PLUGS_IOT,
*PLUGS_SMART,
}
STRIPS_IOT = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"}
STRIPS_SMART = {} # type: ignore[var-annotated]
STRIPS = {*STRIPS_IOT, *STRIPS_SMART}

DIMMERS_IOT = {"ES20M", "HS220", "KS220M", "KS230", "KP405"}
DIMMERS_SMART = {} # type: ignore[var-annotated]
DIMMERS = {
*DIMMERS_IOT,
*DIMMERS_SMART,
}

STRIPS = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"}
DIMMERS = {"ES20M", "HS220", "KS220M", "KS230", "KP405"}
WITH_EMETER_IOT = {"HS110", "HS300", "KP115", "KP125", *BULBS_IOT}
WITH_EMETER_SMART = {*PLUGS_SMART}
WITH_EMETER = {*WITH_EMETER_IOT, *WITH_EMETER_SMART}

DIMMABLE = {*BULBS, *DIMMERS}
WITH_EMETER = {"HS110", "HS300", "KP115", "KP125", "KP125M", *BULBS}

ALL_DEVICES_IOT = BULBS.union(PLUGS).union(STRIPS).union(DIMMERS)

PLUGS_SMART = {"P110", "KP125M"}
ALL_DEVICES_SMART = BULBS_SMART.union(PLUGS_SMART)

ALL_DEVICES_IOT = BULBS_IOT.union(PLUGS_IOT).union(STRIPS_IOT).union(DIMMERS_IOT)
ALL_DEVICES_SMART = (
BULBS_SMART.union(PLUGS_SMART).union(STRIPS_SMART).union(DIMMERS_SMART)
)
ALL_DEVICES = ALL_DEVICES_IOT.union(ALL_DEVICES_SMART)

IP_MODEL_CACHE: Dict[str, str] = {}
Expand All @@ -126,14 +139,15 @@ def idgenerator(paramtuple):


def filter_model(desc, model_filter, protocol_filter=None):
if not protocol_filter:
protocol_filter = {"IOT"}
if protocol_filter is None:
protocol_filter = {"IOT", "SMART"}
filtered = list()
for file, protocol in SUPPORTED_DEVICES:
if protocol in protocol_filter:
file_model = basename(file).split("_")[0]
file_model_region = basename(file).split("_")[0]
file_model = file_model_region.split("(")[0]
for model in model_filter:
if model in file_model:
if model == file_model:
filtered.append((file, protocol))

filtered_basenames = [basename(f) + "-" + p for f, p in filtered]
Expand All @@ -151,30 +165,40 @@ def parametrize(desc, devices, protocol_filter=None, ids=None):
)


has_emeter = parametrize("has emeter", WITH_EMETER)
no_emeter = parametrize("no emeter", ALL_DEVICES_IOT - WITH_EMETER)
has_emeter = parametrize("has emeter", WITH_EMETER_IOT, protocol_filter={"IOT"})
no_emeter = parametrize(
"no emeter", ALL_DEVICES_IOT - WITH_EMETER_IOT, protocol_filter={"SMART", "IOT"}
)

bulb = parametrize("bulbs", BULBS, protocol_filter={"SMART", "IOT"})
plug = parametrize("plugs", PLUGS)
strip = parametrize("strips", STRIPS)
dimmer = parametrize("dimmers", DIMMERS)
lightstrip = parametrize("lightstrips", LIGHT_STRIPS)
plug = parametrize("plugs", PLUGS, protocol_filter={"IOT"})
strip = parametrize("strips", STRIPS, protocol_filter={"IOT"})
dimmer = parametrize("dimmers", DIMMERS, protocol_filter={"IOT"})
lightstrip = parametrize("lightstrips", LIGHT_STRIPS, protocol_filter={"IOT"})

# bulb types
dimmable = parametrize("dimmable", DIMMABLE)
non_dimmable = parametrize("non-dimmable", BULBS - DIMMABLE)
dimmable = parametrize("dimmable", DIMMABLE, protocol_filter={"IOT"})
non_dimmable = parametrize("non-dimmable", BULBS - DIMMABLE, protocol_filter={"IOT"})
variable_temp = parametrize(
"variable color temp", BULBS_VARIABLE_TEMP, {"SMART", "IOT"}
"variable color temp", BULBS_VARIABLE_TEMP, protocol_filter={"SMART", "IOT"}
)
non_variable_temp = parametrize(
"non-variable color temp", BULBS - BULBS_VARIABLE_TEMP, {"SMART", "IOT"}
"non-variable color temp",
BULBS - BULBS_VARIABLE_TEMP,
protocol_filter={"SMART", "IOT"},
)
color_bulb = parametrize("color bulbs", BULBS_COLOR, protocol_filter={"SMART", "IOT"})
non_color_bulb = parametrize(
"non-color bulbs", BULBS - BULBS_COLOR, protocol_filter={"SMART", "IOT"}
)
color_bulb = parametrize("color bulbs", BULBS_COLOR, {"SMART", "IOT"})
non_color_bulb = parametrize("non-color bulbs", BULBS - BULBS_COLOR, {"SMART", "IOT"})

color_bulb_iot = parametrize("color bulbs iot", BULBS_COLOR, {"IOT"})
variable_temp_iot = parametrize("variable color temp iot", BULBS_VARIABLE_TEMP, {"IOT"})
bulb_iot = parametrize("bulb devices iot", BULBS_IOT)
color_bulb_iot = parametrize(
"color bulbs iot", BULBS_IOT_COLOR, protocol_filter={"IOT"}
)
variable_temp_iot = parametrize(
"variable color temp iot", BULBS_IOT_VARIABLE_TEMP, protocol_filter={"IOT"}
)
bulb_iot = parametrize("bulb devices iot", BULBS_IOT, protocol_filter={"IOT"})

plug_smart = parametrize("plug devices smart", PLUGS_SMART, protocol_filter={"SMART"})
bulb_smart = parametrize("bulb devices smart", BULBS_SMART, protocol_filter={"SMART"})
Expand Down Expand Up @@ -209,7 +233,9 @@ def filter_fixtures(desc, root_filter):
if root_filter in val:
filtered[key] = val

print(f"{desc}: {filtered.keys()}")
print(f"# {desc}")
for key in filtered:
print(f"\t{key}")
return filtered


Expand Down Expand Up @@ -268,11 +294,11 @@ def device_for_file(model, protocol):
if d in model:
return TapoBulb
else:
for d in STRIPS:
for d in STRIPS_IOT:
if d in model:
return SmartStrip

for d in PLUGS:
for d in PLUGS_IOT:
if d in model:
return SmartPlug

Expand All @@ -281,11 +307,11 @@ def device_for_file(model, protocol):
if d in model:
return SmartLightStrip

for d in BULBS:
for d in BULBS_IOT:
if d in model:
return SmartBulb

for d in DIMMERS:
for d in DIMMERS_IOT:
if d in model:
return SmartDimmer

Expand Down
Loading