diff --git a/README.md b/README.md index ad9b43eb..90c9ac0f 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ The following devices have been tested and confirmed as working. If your device - **Plugs**: EP10, EP25[^1], HS100[^2], HS103, HS105, HS110, KP100, KP105, KP115, KP125, KP125M[^1], KP401 - **Power Strips**: EP40, EP40M[^1], HS107, HS300, KP200, KP303, KP400 -- **Wall Switches**: ES20M, HS200[^2], HS210, HS220[^2], KP405, KS200M, KS205[^1], KS220, KS220M, KS225[^1], KS230, KS240[^1] +- **Wall Switches**: ES20M, HS200[^2], HS210, HS220[^2], KP405, KS200, KS200M, KS205[^1], KS220, KS220M, KS225[^1], KS230, KS240[^1] - **Bulbs**: KL110, KL120, KL125, KL130, KL135, KL50, KL60, LB110 - **Light Strips**: KL400L5, KL420L5, KL430 - **Hubs**: KH100[^1] diff --git a/SUPPORTED.md b/SUPPORTED.md index e5f01f9f..ba7726cc 100644 --- a/SUPPORTED.md +++ b/SUPPORTED.md @@ -97,6 +97,8 @@ Some newer Kasa devices require authentication. These are marked with [^1] in th - **KP405** - Hardware: 1.0 (US) / Firmware: 1.0.5 - Hardware: 1.0 (US) / Firmware: 1.0.6 +- **KS200** + - Hardware: 1.0 (US) / Firmware: 1.0.8 - **KS200M** - Hardware: 1.0 (US) / Firmware: 1.0.10 - Hardware: 1.0 (US) / Firmware: 1.0.11 @@ -192,6 +194,7 @@ All Tapo devices require authentication.
Hub-Connected Devices may work acros - Hardware: 1.0 (EU) / Firmware: 1.2.3 - **P115** - Hardware: 1.0 (EU) / Firmware: 1.2.3 + - Hardware: 1.0 (US) / Firmware: 1.1.3 - **P125M** - Hardware: 1.0 (US) / Firmware: 1.1.0 - **P135** diff --git a/tests/device_fixtures.py b/tests/device_fixtures.py index d206b714..3ab96c18 100644 --- a/tests/device_fixtures.py +++ b/tests/device_fixtures.py @@ -1,543 +1,544 @@ -from __future__ import annotations - -import os -from collections.abc import AsyncGenerator - -import pytest - -from kasa import ( - Credentials, - Device, - DeviceType, - Discover, -) -from kasa.iot import IotBulb, IotDimmer, IotLightStrip, IotPlug, IotStrip, IotWallSwitch -from kasa.smart import SmartDevice -from kasa.smartcam import SmartCamDevice - -from .fakeprotocol_iot import FakeIotProtocol -from .fakeprotocol_smart import FakeSmartProtocol -from .fakeprotocol_smartcam import FakeSmartCamProtocol -from .fixtureinfo import ( - FIXTURE_DATA, - ComponentFilter, - FixtureInfo, - filter_fixtures, - idgenerator, -) - -# Tapo bulbs -BULBS_SMART_VARIABLE_TEMP = {"L530E", "L930-5"} -BULBS_SMART_LIGHT_STRIP = {"L900-5", "L900-10", "L920-5", "L930-5"} -BULBS_SMART_COLOR = {"L530E", *BULBS_SMART_LIGHT_STRIP} -BULBS_SMART_DIMMABLE = {"L510B", "L510E"} -BULBS_SMART = ( - BULBS_SMART_VARIABLE_TEMP.union(BULBS_SMART_COLOR) - .union(BULBS_SMART_DIMMABLE) - .union(BULBS_SMART_LIGHT_STRIP) -) - -# Kasa (IOT-prefixed) bulbs -BULBS_IOT_LIGHT_STRIP = {"KL400L5", "KL430", "KL420L5"} -BULBS_IOT_VARIABLE_TEMP = { - "LB120", - "LB130", - "KL120", - "KL125", - "KL130", - "KL135", - "KL430", -} -BULBS_IOT_COLOR = {"LB130", "KL125", "KL130", "KL135", *BULBS_IOT_LIGHT_STRIP} -BULBS_IOT_DIMMABLE = {"KL50", "KL60", "LB100", "LB110", "KL110"} -BULBS_IOT = ( - BULBS_IOT_VARIABLE_TEMP.union(BULBS_IOT_COLOR) - .union(BULBS_IOT_DIMMABLE) - .union(BULBS_IOT_LIGHT_STRIP) -) - -BULBS_VARIABLE_TEMP = {*BULBS_SMART_VARIABLE_TEMP, *BULBS_IOT_VARIABLE_TEMP} -BULBS_COLOR = {*BULBS_SMART_COLOR, *BULBS_IOT_COLOR} - - -LIGHT_STRIPS = {*BULBS_SMART_LIGHT_STRIP, *BULBS_IOT_LIGHT_STRIP} -BULBS = { - *BULBS_IOT, - *BULBS_SMART, -} - - -PLUGS_IOT = { - "HS100", - "HS103", - "HS105", - "HS110", - "EP10", - "KP100", - "KP105", - "KP115", - "KP125", - "KP401", -} -# P135 supports dimming, but its not currently support -# by the library -PLUGS_SMART = { - "P100", - "P110", - "P110M", - "P115", - "KP125M", - "EP25", - "P125M", - "TP15", -} -PLUGS = { - *PLUGS_IOT, - *PLUGS_SMART, -} -SWITCHES_IOT = { - "HS200", - "HS210", - "KS200M", -} -SWITCHES_SMART = { - "HS200", - "KS205", - "KS225", - "KS240", - "S500D", - "S505", - "S505D", -} -SWITCHES = {*SWITCHES_IOT, *SWITCHES_SMART} -STRIPS_IOT = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"} -STRIPS_SMART = {"P300", "P304M", "TP25", "EP40M"} -STRIPS = {*STRIPS_IOT, *STRIPS_SMART} - -DIMMERS_IOT = {"ES20M", "HS220", "KS220", "KS220M", "KS230", "KP405"} -DIMMERS_SMART = {"HS220", "KS225", "S500D", "P135"} -DIMMERS = { - *DIMMERS_IOT, - *DIMMERS_SMART, -} - -HUBS_SMART = {"H100", "KH100"} -SENSORS_SMART = {"T310", "T315", "T300", "T100", "T110", "S200B", "S200D"} -THERMOSTATS_SMART = {"KE100"} - -WITH_EMETER_IOT = {"HS110", "HS300", "KP115", "KP125", *BULBS_IOT} -WITH_EMETER_SMART = {"P110", "P110M", "P115", "KP125M", "EP25", "P304M"} -WITH_EMETER = {*WITH_EMETER_IOT, *WITH_EMETER_SMART} - -DIMMABLE = {*BULBS, *DIMMERS} - -ALL_DEVICES_IOT = ( - BULBS_IOT.union(PLUGS_IOT).union(STRIPS_IOT).union(DIMMERS_IOT).union(SWITCHES_IOT) -) -ALL_DEVICES_SMART = ( - BULBS_SMART.union(PLUGS_SMART) - .union(STRIPS_SMART) - .union(DIMMERS_SMART) - .union(HUBS_SMART) - .union(SENSORS_SMART) - .union(SWITCHES_SMART) - .union(THERMOSTATS_SMART) -) -ALL_DEVICES = ALL_DEVICES_IOT.union(ALL_DEVICES_SMART) - -IP_FIXTURE_CACHE: dict[str, FixtureInfo] = {} - - -def parametrize_combine(parametrized: list[pytest.MarkDecorator]): - """Combine multiple pytest parametrize dev marks into one set of fixtures.""" - fixtures = set() - for param in parametrized: - if param.args[0] != "dev": - raise Exception(f"Supplied mark is not for dev fixture: {param.args[0]}") - fixtures.update(param.args[1]) - return pytest.mark.parametrize( - "dev", - sorted(list(fixtures)), - indirect=True, - ids=idgenerator, - ) - - -def parametrize_subtract(params: pytest.MarkDecorator, subtract: pytest.MarkDecorator): - """Combine multiple pytest parametrize dev marks into one set of fixtures.""" - if params.args[0] != "dev" or subtract.args[0] != "dev": - raise Exception( - f"Supplied mark is not for dev fixture: {params.args[0]} {subtract.args[0]}" - ) - fixtures = [] - for param in params.args[1]: - if param not in subtract.args[1]: - fixtures.append(param) - return pytest.mark.parametrize( - "dev", - sorted(fixtures), - indirect=True, - ids=idgenerator, - ) - - -def parametrize( - desc, - *, - model_filter=None, - protocol_filter=None, - component_filter: str | ComponentFilter | None = None, - data_root_filter=None, - device_type_filter=None, - ids=None, - fixture_name="dev", -): - if ids is None: - ids = idgenerator - return pytest.mark.parametrize( - fixture_name, - filter_fixtures( - desc, - model_filter=model_filter, - protocol_filter=protocol_filter, - component_filter=component_filter, - data_root_filter=data_root_filter, - device_type_filter=device_type_filter, - ), - indirect=True, - ids=ids, - ) - - -has_emeter = parametrize( - "has emeter", model_filter=WITH_EMETER, protocol_filter={"SMART", "IOT"} -) -no_emeter = parametrize( - "no emeter", - model_filter=ALL_DEVICES - WITH_EMETER, - protocol_filter={"SMART", "IOT"}, -) -has_emeter_smart = parametrize( - "has emeter smart", model_filter=WITH_EMETER_SMART, protocol_filter={"SMART"} -) -has_emeter_iot = parametrize( - "has emeter iot", model_filter=WITH_EMETER_IOT, protocol_filter={"IOT"} -) -no_emeter_iot = parametrize( - "no emeter iot", - model_filter=ALL_DEVICES_IOT - WITH_EMETER_IOT, - protocol_filter={"IOT"}, -) - -plug = parametrize("plugs", model_filter=PLUGS, protocol_filter={"IOT", "SMART"}) -plug_iot = parametrize("plugs iot", model_filter=PLUGS, protocol_filter={"IOT"}) -wallswitch = parametrize( - "wall switches", model_filter=SWITCHES, protocol_filter={"IOT", "SMART"} -) -wallswitch_iot = parametrize( - "wall switches iot", model_filter=SWITCHES, protocol_filter={"IOT"} -) -strip = parametrize("strips", model_filter=STRIPS, protocol_filter={"SMART", "IOT"}) -dimmer_iot = parametrize("dimmers", model_filter=DIMMERS, protocol_filter={"IOT"}) -lightstrip_iot = parametrize( - "lightstrips", model_filter=LIGHT_STRIPS, protocol_filter={"IOT"} -) - -# bulb types -dimmable_iot = parametrize("dimmable", model_filter=DIMMABLE, protocol_filter={"IOT"}) -non_dimmable_iot = parametrize( - "non-dimmable", model_filter=BULBS - DIMMABLE, protocol_filter={"IOT"} -) -variable_temp = parametrize( - "variable color temp", - model_filter=BULBS_VARIABLE_TEMP, - protocol_filter={"SMART", "IOT"}, -) -non_variable_temp = parametrize( - "non-variable color temp", - model_filter=BULBS - BULBS_VARIABLE_TEMP, - protocol_filter={"SMART", "IOT"}, -) -color_bulb = parametrize( - "color bulbs", model_filter=BULBS_COLOR, protocol_filter={"SMART", "IOT"} -) -non_color_bulb = parametrize( - "non-color bulbs", - model_filter=BULBS - BULBS_COLOR, - protocol_filter={"SMART", "IOT"}, -) - -color_bulb_iot = parametrize( - "color bulbs iot", model_filter=BULBS_IOT_COLOR, protocol_filter={"IOT"} -) -variable_temp_iot = parametrize( - "variable color temp iot", - model_filter=BULBS_IOT_VARIABLE_TEMP, - protocol_filter={"IOT"}, -) -variable_temp_smart = parametrize( - "variable color temp smart", - model_filter=BULBS_SMART_VARIABLE_TEMP, - protocol_filter={"SMART"}, -) - -bulb_smart = parametrize( - "bulb devices smart", - device_type_filter=[DeviceType.Bulb, DeviceType.LightStrip], - protocol_filter={"SMART"}, -) -bulb_iot = parametrize( - "bulb devices iot", model_filter=BULBS_IOT, protocol_filter={"IOT"} -) -bulb = parametrize_combine([bulb_smart, bulb_iot]) - -strip_iot = parametrize( - "strip devices iot", model_filter=STRIPS_IOT, protocol_filter={"IOT"} -) -strip_smart = parametrize( - "strip devices smart", model_filter=STRIPS_SMART, protocol_filter={"SMART"} -) - -plug_smart = parametrize( - "plug devices smart", model_filter=PLUGS_SMART, protocol_filter={"SMART"} -) -switch_smart = parametrize( - "switch devices smart", model_filter=SWITCHES_SMART, protocol_filter={"SMART"} -) -dimmers_smart = parametrize( - "dimmer devices smart", model_filter=DIMMERS_SMART, protocol_filter={"SMART"} -) -hubs_smart = parametrize( - "hubs smart", model_filter=HUBS_SMART, protocol_filter={"SMART"} -) -sensors_smart = parametrize( - "sensors smart", model_filter=SENSORS_SMART, protocol_filter={"SMART.CHILD"} -) -thermostats_smart = parametrize( - "thermostats smart", model_filter=THERMOSTATS_SMART, protocol_filter={"SMART.CHILD"} -) -device_smart = parametrize( - "devices smart", model_filter=ALL_DEVICES_SMART, protocol_filter={"SMART"} -) -device_iot = parametrize( - "devices iot", model_filter=ALL_DEVICES_IOT, protocol_filter={"IOT"} -) -device_smartcam = parametrize("devices smartcam", protocol_filter={"SMARTCAM"}) -camera_smartcam = parametrize( - "camera smartcam", - device_type_filter=[DeviceType.Camera], - protocol_filter={"SMARTCAM"}, -) -hub_smartcam = parametrize( - "hub smartcam", - device_type_filter=[DeviceType.Hub], - protocol_filter={"SMARTCAM"}, -) - - -def check_categories(): - """Check that every fixture file is categorized.""" - categorized_fixtures = set( - dimmer_iot.args[1] - + strip.args[1] - + plug.args[1] - + bulb.args[1] - + wallswitch.args[1] - + lightstrip_iot.args[1] - + bulb_smart.args[1] - + dimmers_smart.args[1] - + hubs_smart.args[1] - + sensors_smart.args[1] - + thermostats_smart.args[1] - + camera_smartcam.args[1] - + hub_smartcam.args[1] - ) - diffs: set[FixtureInfo] = set(FIXTURE_DATA) - set(categorized_fixtures) - if diffs: - print(diffs) - for diff in diffs: - print( - f"No category for file {diff.name} protocol {diff.protocol}, add to the corresponding set (BULBS, PLUGS, ..)" - ) - raise Exception(f"Missing category for {diff.name}") - - -check_categories() - - -def device_for_fixture_name(model, protocol): - if protocol in {"SMART", "SMART.CHILD"}: - return SmartDevice - elif protocol == "SMARTCAM": - return SmartCamDevice - else: - for d in STRIPS_IOT: - if d in model: - return IotStrip - - for d in PLUGS_IOT: - if d in model: - return IotPlug - for d in SWITCHES_IOT: - if d in model: - return IotWallSwitch - - # Light strips are recognized also as bulbs, so this has to go first - for d in BULBS_IOT_LIGHT_STRIP: - if d in model: - return IotLightStrip - - for d in BULBS_IOT: - if d in model: - return IotBulb - - for d in DIMMERS_IOT: - if d in model: - return IotDimmer - - raise Exception("Unable to find type for %s", model) - - -async def _update_and_close(d) -> Device: - await d.update() - await d.protocol.close() - return d - - -async def _discover_update_and_close(ip, username, password) -> Device: - if username and password: - credentials = Credentials(username=username, password=password) - else: - credentials = None - d = await Discover.discover_single(ip, timeout=10, credentials=credentials) - return await _update_and_close(d) - - -async def get_device_for_fixture( - fixture_data: FixtureInfo, *, verbatim=False, update_after_init=True -) -> Device: - # if the wanted file is not an absolute path, prepend the fixtures directory - - d = device_for_fixture_name(fixture_data.name, fixture_data.protocol)( - host="127.0.0.123" - ) - if fixture_data.protocol in {"SMART", "SMART.CHILD"}: - d.protocol = FakeSmartProtocol( - fixture_data.data, fixture_data.name, verbatim=verbatim - ) - elif fixture_data.protocol == "SMARTCAM": - d.protocol = FakeSmartCamProtocol( - fixture_data.data, fixture_data.name, verbatim=verbatim - ) - else: - d.protocol = FakeIotProtocol(fixture_data.data, verbatim=verbatim) - - discovery_data = None - if "discovery_result" in fixture_data.data: - discovery_data = fixture_data.data["discovery_result"] - elif "system" in fixture_data.data: - discovery_data = { - "system": {"get_sysinfo": fixture_data.data["system"]["get_sysinfo"]} - } - - if discovery_data: # Child devices do not have discovery info - d.update_from_discover_info(discovery_data) - - if update_after_init: - await _update_and_close(d) - return d - - -async def get_device_for_fixture_protocol(fixture, protocol): - finfo = FixtureInfo(name=fixture, protocol=protocol, data={}) - for fixture_info in FIXTURE_DATA: - if finfo == fixture_info: - return await get_device_for_fixture(fixture_info) - - -def get_fixture_info(fixture, protocol): - finfo = FixtureInfo(name=fixture, protocol=protocol, data={}) - for fixture_info in FIXTURE_DATA: - if finfo == fixture_info: - return fixture_info - - -def get_nearest_fixture_to_ip(dev): - if isinstance(dev, SmartDevice): - protocol_fixtures = filter_fixtures("", protocol_filter={"SMART"}) - elif isinstance(dev, SmartCamDevice): - protocol_fixtures = filter_fixtures("", protocol_filter={"SMARTCAM"}) - else: - protocol_fixtures = filter_fixtures("", protocol_filter={"IOT"}) - assert protocol_fixtures, "Unknown device type" - - # This will get the best fixture with a match on model region - if model_region_fixtures := filter_fixtures( - "", model_filter={dev._model_region}, fixture_list=protocol_fixtures - ): - return next(iter(model_region_fixtures)) - - # This will get the best fixture based on model starting with the name. - if "(" in dev.model: - model, _, _ = dev.model.partition("(") - else: - model = dev.model - if model_fixtures := filter_fixtures( - "", model_startswith_filter=model, fixture_list=protocol_fixtures - ): - return next(iter(model_fixtures)) - - if device_type_fixtures := filter_fixtures( - "", device_type_filter={dev.device_type}, fixture_list=protocol_fixtures - ): - return next(iter(device_type_fixtures)) - - return next(iter(protocol_fixtures)) - - -@pytest.fixture(params=filter_fixtures("main devices"), ids=idgenerator) -async def dev(request) -> AsyncGenerator[Device, None]: - """Device fixture. - - Provides a device (given --ip) or parametrized fixture for the supported devices. - The initial update is called automatically before returning the device. - """ - fixture_data: FixtureInfo = request.param - dev: Device - - ip = request.config.getoption("--ip") - username = request.config.getoption("--username") or os.environ.get("KASA_USERNAME") - password = request.config.getoption("--password") or os.environ.get("KASA_PASSWORD") - if ip: - fixture = IP_FIXTURE_CACHE.get(ip) - - d = None - if not fixture: - d = await _discover_update_and_close(ip, username, password) - IP_FIXTURE_CACHE[ip] = fixture = get_nearest_fixture_to_ip(d) - assert fixture - if fixture.name != fixture_data.name: - pytest.skip(f"skipping file {fixture_data.name}") - dev = None - else: - dev = d if d else await _discover_update_and_close(ip, username, password) - else: - dev = await get_device_for_fixture(fixture_data) - - yield dev - - if dev: - await dev.disconnect() - - -def get_parent_and_child_modules(device: Device, module_name): - """Return iterator of module if exists on parent and children. - - Useful for testing devices that have components listed on the parent that are only - supported on the children, i.e. ks240. - """ - if module_name in device.modules: - yield device.modules[module_name] - for child in device.children: - if module_name in child.modules: - yield child.modules[module_name] +from __future__ import annotations + +import os +from collections.abc import AsyncGenerator + +import pytest + +from kasa import ( + Credentials, + Device, + DeviceType, + Discover, +) +from kasa.iot import IotBulb, IotDimmer, IotLightStrip, IotPlug, IotStrip, IotWallSwitch +from kasa.smart import SmartDevice +from kasa.smartcam import SmartCamDevice + +from .fakeprotocol_iot import FakeIotProtocol +from .fakeprotocol_smart import FakeSmartProtocol +from .fakeprotocol_smartcam import FakeSmartCamProtocol +from .fixtureinfo import ( + FIXTURE_DATA, + ComponentFilter, + FixtureInfo, + filter_fixtures, + idgenerator, +) + +# Tapo bulbs +BULBS_SMART_VARIABLE_TEMP = {"L530E", "L930-5"} +BULBS_SMART_LIGHT_STRIP = {"L900-5", "L900-10", "L920-5", "L930-5"} +BULBS_SMART_COLOR = {"L530E", *BULBS_SMART_LIGHT_STRIP} +BULBS_SMART_DIMMABLE = {"L510B", "L510E"} +BULBS_SMART = ( + BULBS_SMART_VARIABLE_TEMP.union(BULBS_SMART_COLOR) + .union(BULBS_SMART_DIMMABLE) + .union(BULBS_SMART_LIGHT_STRIP) +) + +# Kasa (IOT-prefixed) bulbs +BULBS_IOT_LIGHT_STRIP = {"KL400L5", "KL430", "KL420L5"} +BULBS_IOT_VARIABLE_TEMP = { + "LB120", + "LB130", + "KL120", + "KL125", + "KL130", + "KL135", + "KL430", +} +BULBS_IOT_COLOR = {"LB130", "KL125", "KL130", "KL135", *BULBS_IOT_LIGHT_STRIP} +BULBS_IOT_DIMMABLE = {"KL50", "KL60", "LB100", "LB110", "KL110"} +BULBS_IOT = ( + BULBS_IOT_VARIABLE_TEMP.union(BULBS_IOT_COLOR) + .union(BULBS_IOT_DIMMABLE) + .union(BULBS_IOT_LIGHT_STRIP) +) + +BULBS_VARIABLE_TEMP = {*BULBS_SMART_VARIABLE_TEMP, *BULBS_IOT_VARIABLE_TEMP} +BULBS_COLOR = {*BULBS_SMART_COLOR, *BULBS_IOT_COLOR} + + +LIGHT_STRIPS = {*BULBS_SMART_LIGHT_STRIP, *BULBS_IOT_LIGHT_STRIP} +BULBS = { + *BULBS_IOT, + *BULBS_SMART, +} + + +PLUGS_IOT = { + "HS100", + "HS103", + "HS105", + "HS110", + "EP10", + "KP100", + "KP105", + "KP115", + "KP125", + "KP401", +} +# P135 supports dimming, but its not currently support +# by the library +PLUGS_SMART = { + "P100", + "P110", + "P110M", + "P115", + "KP125M", + "EP25", + "P125M", + "TP15", +} +PLUGS = { + *PLUGS_IOT, + *PLUGS_SMART, +} +SWITCHES_IOT = { + "HS200", + "HS210", + "KS200", + "KS200M", +} +SWITCHES_SMART = { + "HS200", + "KS205", + "KS225", + "KS240", + "S500D", + "S505", + "S505D", +} +SWITCHES = {*SWITCHES_IOT, *SWITCHES_SMART} +STRIPS_IOT = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"} +STRIPS_SMART = {"P300", "P304M", "TP25", "EP40M"} +STRIPS = {*STRIPS_IOT, *STRIPS_SMART} + +DIMMERS_IOT = {"ES20M", "HS220", "KS220", "KS220M", "KS230", "KP405"} +DIMMERS_SMART = {"HS220", "KS225", "S500D", "P135"} +DIMMERS = { + *DIMMERS_IOT, + *DIMMERS_SMART, +} + +HUBS_SMART = {"H100", "KH100"} +SENSORS_SMART = {"T310", "T315", "T300", "T100", "T110", "S200B", "S200D"} +THERMOSTATS_SMART = {"KE100"} + +WITH_EMETER_IOT = {"HS110", "HS300", "KP115", "KP125", *BULBS_IOT} +WITH_EMETER_SMART = {"P110", "P110M", "P115", "KP125M", "EP25", "P304M"} +WITH_EMETER = {*WITH_EMETER_IOT, *WITH_EMETER_SMART} + +DIMMABLE = {*BULBS, *DIMMERS} + +ALL_DEVICES_IOT = ( + BULBS_IOT.union(PLUGS_IOT).union(STRIPS_IOT).union(DIMMERS_IOT).union(SWITCHES_IOT) +) +ALL_DEVICES_SMART = ( + BULBS_SMART.union(PLUGS_SMART) + .union(STRIPS_SMART) + .union(DIMMERS_SMART) + .union(HUBS_SMART) + .union(SENSORS_SMART) + .union(SWITCHES_SMART) + .union(THERMOSTATS_SMART) +) +ALL_DEVICES = ALL_DEVICES_IOT.union(ALL_DEVICES_SMART) + +IP_FIXTURE_CACHE: dict[str, FixtureInfo] = {} + + +def parametrize_combine(parametrized: list[pytest.MarkDecorator]): + """Combine multiple pytest parametrize dev marks into one set of fixtures.""" + fixtures = set() + for param in parametrized: + if param.args[0] != "dev": + raise Exception(f"Supplied mark is not for dev fixture: {param.args[0]}") + fixtures.update(param.args[1]) + return pytest.mark.parametrize( + "dev", + sorted(list(fixtures)), + indirect=True, + ids=idgenerator, + ) + + +def parametrize_subtract(params: pytest.MarkDecorator, subtract: pytest.MarkDecorator): + """Combine multiple pytest parametrize dev marks into one set of fixtures.""" + if params.args[0] != "dev" or subtract.args[0] != "dev": + raise Exception( + f"Supplied mark is not for dev fixture: {params.args[0]} {subtract.args[0]}" + ) + fixtures = [] + for param in params.args[1]: + if param not in subtract.args[1]: + fixtures.append(param) + return pytest.mark.parametrize( + "dev", + sorted(fixtures), + indirect=True, + ids=idgenerator, + ) + + +def parametrize( + desc, + *, + model_filter=None, + protocol_filter=None, + component_filter: str | ComponentFilter | None = None, + data_root_filter=None, + device_type_filter=None, + ids=None, + fixture_name="dev", +): + if ids is None: + ids = idgenerator + return pytest.mark.parametrize( + fixture_name, + filter_fixtures( + desc, + model_filter=model_filter, + protocol_filter=protocol_filter, + component_filter=component_filter, + data_root_filter=data_root_filter, + device_type_filter=device_type_filter, + ), + indirect=True, + ids=ids, + ) + + +has_emeter = parametrize( + "has emeter", model_filter=WITH_EMETER, protocol_filter={"SMART", "IOT"} +) +no_emeter = parametrize( + "no emeter", + model_filter=ALL_DEVICES - WITH_EMETER, + protocol_filter={"SMART", "IOT"}, +) +has_emeter_smart = parametrize( + "has emeter smart", model_filter=WITH_EMETER_SMART, protocol_filter={"SMART"} +) +has_emeter_iot = parametrize( + "has emeter iot", model_filter=WITH_EMETER_IOT, protocol_filter={"IOT"} +) +no_emeter_iot = parametrize( + "no emeter iot", + model_filter=ALL_DEVICES_IOT - WITH_EMETER_IOT, + protocol_filter={"IOT"}, +) + +plug = parametrize("plugs", model_filter=PLUGS, protocol_filter={"IOT", "SMART"}) +plug_iot = parametrize("plugs iot", model_filter=PLUGS, protocol_filter={"IOT"}) +wallswitch = parametrize( + "wall switches", model_filter=SWITCHES, protocol_filter={"IOT", "SMART"} +) +wallswitch_iot = parametrize( + "wall switches iot", model_filter=SWITCHES, protocol_filter={"IOT"} +) +strip = parametrize("strips", model_filter=STRIPS, protocol_filter={"SMART", "IOT"}) +dimmer_iot = parametrize("dimmers", model_filter=DIMMERS, protocol_filter={"IOT"}) +lightstrip_iot = parametrize( + "lightstrips", model_filter=LIGHT_STRIPS, protocol_filter={"IOT"} +) + +# bulb types +dimmable_iot = parametrize("dimmable", model_filter=DIMMABLE, protocol_filter={"IOT"}) +non_dimmable_iot = parametrize( + "non-dimmable", model_filter=BULBS - DIMMABLE, protocol_filter={"IOT"} +) +variable_temp = parametrize( + "variable color temp", + model_filter=BULBS_VARIABLE_TEMP, + protocol_filter={"SMART", "IOT"}, +) +non_variable_temp = parametrize( + "non-variable color temp", + model_filter=BULBS - BULBS_VARIABLE_TEMP, + protocol_filter={"SMART", "IOT"}, +) +color_bulb = parametrize( + "color bulbs", model_filter=BULBS_COLOR, protocol_filter={"SMART", "IOT"} +) +non_color_bulb = parametrize( + "non-color bulbs", + model_filter=BULBS - BULBS_COLOR, + protocol_filter={"SMART", "IOT"}, +) + +color_bulb_iot = parametrize( + "color bulbs iot", model_filter=BULBS_IOT_COLOR, protocol_filter={"IOT"} +) +variable_temp_iot = parametrize( + "variable color temp iot", + model_filter=BULBS_IOT_VARIABLE_TEMP, + protocol_filter={"IOT"}, +) +variable_temp_smart = parametrize( + "variable color temp smart", + model_filter=BULBS_SMART_VARIABLE_TEMP, + protocol_filter={"SMART"}, +) + +bulb_smart = parametrize( + "bulb devices smart", + device_type_filter=[DeviceType.Bulb, DeviceType.LightStrip], + protocol_filter={"SMART"}, +) +bulb_iot = parametrize( + "bulb devices iot", model_filter=BULBS_IOT, protocol_filter={"IOT"} +) +bulb = parametrize_combine([bulb_smart, bulb_iot]) + +strip_iot = parametrize( + "strip devices iot", model_filter=STRIPS_IOT, protocol_filter={"IOT"} +) +strip_smart = parametrize( + "strip devices smart", model_filter=STRIPS_SMART, protocol_filter={"SMART"} +) + +plug_smart = parametrize( + "plug devices smart", model_filter=PLUGS_SMART, protocol_filter={"SMART"} +) +switch_smart = parametrize( + "switch devices smart", model_filter=SWITCHES_SMART, protocol_filter={"SMART"} +) +dimmers_smart = parametrize( + "dimmer devices smart", model_filter=DIMMERS_SMART, protocol_filter={"SMART"} +) +hubs_smart = parametrize( + "hubs smart", model_filter=HUBS_SMART, protocol_filter={"SMART"} +) +sensors_smart = parametrize( + "sensors smart", model_filter=SENSORS_SMART, protocol_filter={"SMART.CHILD"} +) +thermostats_smart = parametrize( + "thermostats smart", model_filter=THERMOSTATS_SMART, protocol_filter={"SMART.CHILD"} +) +device_smart = parametrize( + "devices smart", model_filter=ALL_DEVICES_SMART, protocol_filter={"SMART"} +) +device_iot = parametrize( + "devices iot", model_filter=ALL_DEVICES_IOT, protocol_filter={"IOT"} +) +device_smartcam = parametrize("devices smartcam", protocol_filter={"SMARTCAM"}) +camera_smartcam = parametrize( + "camera smartcam", + device_type_filter=[DeviceType.Camera], + protocol_filter={"SMARTCAM"}, +) +hub_smartcam = parametrize( + "hub smartcam", + device_type_filter=[DeviceType.Hub], + protocol_filter={"SMARTCAM"}, +) + + +def check_categories(): + """Check that every fixture file is categorized.""" + categorized_fixtures = set( + dimmer_iot.args[1] + + strip.args[1] + + plug.args[1] + + bulb.args[1] + + wallswitch.args[1] + + lightstrip_iot.args[1] + + bulb_smart.args[1] + + dimmers_smart.args[1] + + hubs_smart.args[1] + + sensors_smart.args[1] + + thermostats_smart.args[1] + + camera_smartcam.args[1] + + hub_smartcam.args[1] + ) + diffs: set[FixtureInfo] = set(FIXTURE_DATA) - set(categorized_fixtures) + if diffs: + print(diffs) + for diff in diffs: + print( + f"No category for file {diff.name} protocol {diff.protocol}, add to the corresponding set (BULBS, PLUGS, ..)" + ) + raise Exception(f"Missing category for {diff.name}") + + +check_categories() + + +def device_for_fixture_name(model, protocol): + if protocol in {"SMART", "SMART.CHILD"}: + return SmartDevice + elif protocol == "SMARTCAM": + return SmartCamDevice + else: + for d in STRIPS_IOT: + if d in model: + return IotStrip + + for d in PLUGS_IOT: + if d in model: + return IotPlug + for d in SWITCHES_IOT: + if d in model: + return IotWallSwitch + + # Light strips are recognized also as bulbs, so this has to go first + for d in BULBS_IOT_LIGHT_STRIP: + if d in model: + return IotLightStrip + + for d in BULBS_IOT: + if d in model: + return IotBulb + + for d in DIMMERS_IOT: + if d in model: + return IotDimmer + + raise Exception("Unable to find type for %s", model) + + +async def _update_and_close(d) -> Device: + await d.update() + await d.protocol.close() + return d + + +async def _discover_update_and_close(ip, username, password) -> Device: + if username and password: + credentials = Credentials(username=username, password=password) + else: + credentials = None + d = await Discover.discover_single(ip, timeout=10, credentials=credentials) + return await _update_and_close(d) + + +async def get_device_for_fixture( + fixture_data: FixtureInfo, *, verbatim=False, update_after_init=True +) -> Device: + # if the wanted file is not an absolute path, prepend the fixtures directory + + d = device_for_fixture_name(fixture_data.name, fixture_data.protocol)( + host="127.0.0.123" + ) + if fixture_data.protocol in {"SMART", "SMART.CHILD"}: + d.protocol = FakeSmartProtocol( + fixture_data.data, fixture_data.name, verbatim=verbatim + ) + elif fixture_data.protocol == "SMARTCAM": + d.protocol = FakeSmartCamProtocol( + fixture_data.data, fixture_data.name, verbatim=verbatim + ) + else: + d.protocol = FakeIotProtocol(fixture_data.data, verbatim=verbatim) + + discovery_data = None + if "discovery_result" in fixture_data.data: + discovery_data = fixture_data.data["discovery_result"] + elif "system" in fixture_data.data: + discovery_data = { + "system": {"get_sysinfo": fixture_data.data["system"]["get_sysinfo"]} + } + + if discovery_data: # Child devices do not have discovery info + d.update_from_discover_info(discovery_data) + + if update_after_init: + await _update_and_close(d) + return d + + +async def get_device_for_fixture_protocol(fixture, protocol): + finfo = FixtureInfo(name=fixture, protocol=protocol, data={}) + for fixture_info in FIXTURE_DATA: + if finfo == fixture_info: + return await get_device_for_fixture(fixture_info) + + +def get_fixture_info(fixture, protocol): + finfo = FixtureInfo(name=fixture, protocol=protocol, data={}) + for fixture_info in FIXTURE_DATA: + if finfo == fixture_info: + return fixture_info + + +def get_nearest_fixture_to_ip(dev): + if isinstance(dev, SmartDevice): + protocol_fixtures = filter_fixtures("", protocol_filter={"SMART"}) + elif isinstance(dev, SmartCamDevice): + protocol_fixtures = filter_fixtures("", protocol_filter={"SMARTCAM"}) + else: + protocol_fixtures = filter_fixtures("", protocol_filter={"IOT"}) + assert protocol_fixtures, "Unknown device type" + + # This will get the best fixture with a match on model region + if model_region_fixtures := filter_fixtures( + "", model_filter={dev._model_region}, fixture_list=protocol_fixtures + ): + return next(iter(model_region_fixtures)) + + # This will get the best fixture based on model starting with the name. + if "(" in dev.model: + model, _, _ = dev.model.partition("(") + else: + model = dev.model + if model_fixtures := filter_fixtures( + "", model_startswith_filter=model, fixture_list=protocol_fixtures + ): + return next(iter(model_fixtures)) + + if device_type_fixtures := filter_fixtures( + "", device_type_filter={dev.device_type}, fixture_list=protocol_fixtures + ): + return next(iter(device_type_fixtures)) + + return next(iter(protocol_fixtures)) + + +@pytest.fixture(params=filter_fixtures("main devices"), ids=idgenerator) +async def dev(request) -> AsyncGenerator[Device, None]: + """Device fixture. + + Provides a device (given --ip) or parametrized fixture for the supported devices. + The initial update is called automatically before returning the device. + """ + fixture_data: FixtureInfo = request.param + dev: Device + + ip = request.config.getoption("--ip") + username = request.config.getoption("--username") or os.environ.get("KASA_USERNAME") + password = request.config.getoption("--password") or os.environ.get("KASA_PASSWORD") + if ip: + fixture = IP_FIXTURE_CACHE.get(ip) + + d = None + if not fixture: + d = await _discover_update_and_close(ip, username, password) + IP_FIXTURE_CACHE[ip] = fixture = get_nearest_fixture_to_ip(d) + assert fixture + if fixture.name != fixture_data.name: + pytest.skip(f"skipping file {fixture_data.name}") + dev = None + else: + dev = d if d else await _discover_update_and_close(ip, username, password) + else: + dev = await get_device_for_fixture(fixture_data) + + yield dev + + if dev: + await dev.disconnect() + + +def get_parent_and_child_modules(device: Device, module_name): + """Return iterator of module if exists on parent and children. + + Useful for testing devices that have components listed on the parent that are only + supported on the children, i.e. ks240. + """ + if module_name in device.modules: + yield device.modules[module_name] + for child in device.children: + if module_name in child.modules: + yield child.modules[module_name] diff --git a/tests/fixtures/iot/KS200(US)_1.0_1.0.8.json b/tests/fixtures/iot/KS200(US)_1.0_1.0.8.json new file mode 100644 index 00000000..58971dd0 --- /dev/null +++ b/tests/fixtures/iot/KS200(US)_1.0_1.0.8.json @@ -0,0 +1,63 @@ +{ + "cnCloud": { + "get_info": { + "binded": 1, + "cld_connection": 1, + "err_code": 0, + "fwDlPage": "", + "fwNotifyType": -1, + "illegalType": 0, + "server": "n-devs.tplinkcloud.com", + "stopConnect": 0, + "tcspInfo": "", + "tcspStatus": 1, + "username": "#MASKED_NAME#" + }, + "get_intl_fw_list": { + "err_code": 0, + "fw_list": [] + } + }, + "schedule": { + "get_next_action": { + "err_code": 0, + "type": -1 + }, + "get_rules": { + "enable": 1, + "err_code": 0, + "rule_list": [], + "version": 2 + } + }, + "system": { + "get_sysinfo": { + "active_mode": "none", + "alias": "#MASKED_NAME#", + "dev_name": "Smart Wi-Fi Light Switch", + "deviceId": "0000000000000000000000000000000000000000", + "err_code": 0, + "feature": "TIM", + "hwId": "00000000000000000000000000000000", + "hw_ver": "1.0", + "icon_hash": "", + "latitude_i": 0, + "led_off": 0, + "longitude_i": 0, + "mac": "A8:42:A1:00:00:00", + "mic_type": "IOT.SMARTPLUGSWITCH", + "model": "KS200(US)", + "next_action": { + "type": -1 + }, + "obd_src": "tplink", + "oemId": "00000000000000000000000000000000", + "on_time": 0, + "relay_state": 0, + "rssi": -46, + "status": "new", + "sw_ver": "1.0.8 Build 240424 Rel.101842", + "updating": 0 + } + } +} diff --git a/tests/fixtures/smart/P115(US)_1.0_1.1.3.json b/tests/fixtures/smart/P115(US)_1.0_1.1.3.json new file mode 100644 index 00000000..70035368 --- /dev/null +++ b/tests/fixtures/smart/P115(US)_1.0_1.1.3.json @@ -0,0 +1,640 @@ +{ + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "wireless", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "led", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + }, + { + "id": "overheat_protection", + "ver_code": 1 + }, + { + "id": "current_protection", + "ver_code": 1 + } + ] + }, + "discovery_result": { + "device_id": "00000000000000000000000000000000", + "device_model": "P115(US)", + "device_type": "SMART.TAPOPLUG", + "factory_default": false, + "ip": "127.0.0.123", + "is_support_iot_cloud": true, + "mac": "B0-19-21-00-00-00", + "mgt_encrypt_schm": { + "encrypt_type": "KLAP", + "http_port": 80, + "is_support_https": false, + "lv": 2 + }, + "obd_src": "tplink", + "owner": "00000000000000000000000000000000" + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_auto_update_info": { + "enable": true, + "random_range": 120, + "time": 180 + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "charging_status": "normal", + "default_states": { + "state": {}, + "type": "last_states" + }, + "device_id": "0000000000000000000000000000000000000000", + "device_on": false, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.1.3 Build 240523 Rel.175054", + "has_set_location_info": true, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.0", + "ip": "127.0.0.123", + "lang": "en_US", + "latitude": 0, + "longitude": 0, + "mac": "B0-19-21-00-00-00", + "model": "P115", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_time": 0, + "overcurrent_status": "normal", + "overheat_status": "normal", + "power_protection_status": "normal", + "region": "America/Indiana/Indianapolis", + "rssi": -54, + "signal_level": 2, + "specs": "US", + "ssid": "I01BU0tFRF9TU0lEIw==", + "time_diff": -300, + "type": "SMART.TAPOPLUG" + }, + "get_device_time": { + "region": "America/Indiana/Indianapolis", + "time_diff": -300, + "timestamp": 1733673137 + }, + "get_device_usage": { + "power_usage": { + "past30": 4376, + "past7": 1879, + "today": 0 + }, + "saved_power": { + "past30": 8618, + "past7": 69, + "today": 0 + }, + "time_usage": { + "past30": 12994, + "past7": 1948, + "today": 0 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 30, + "energy_wh": 1465, + "power_mw": 0, + "voltage_mv": 122133 + }, + "get_emeter_vgain_igain": { + "igain": 11101, + "vgain": 125071 + }, + "get_energy_usage": { + "current_power": 0, + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2024-12-08 10:52:19", + "month_energy": 2532, + "month_runtime": 2630, + "today_energy": 0, + "today_runtime": 0 + }, + "get_fw_download_state": { + "auto_upgrade": false, + "download_progress": 0, + "reboot_time": 5, + "status": 0, + "upgrade_time": 5 + }, + "get_latest_fw": { + "fw_size": 0, + "fw_ver": "1.1.3 Build 240523 Rel.175054", + "hw_id": "", + "need_to_upgrade": false, + "oem_id": "", + "release_date": "", + "release_note": "", + "type": 0 + }, + "get_led_info": { + "bri_config": { + "bri_type": "overall", + "overall_bri": 50 + }, + "led_rule": "always", + "led_status": false, + "night_mode": { + "end_time": 476, + "night_mode_type": "sunrise_sunset", + "start_time": 1040, + "sunrise_offset": 0, + "sunset_offset": 0 + } + }, + "get_max_power": { + "max_power": 1934 + }, + "get_next_event": {}, + "get_protection_power": { + "enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + }, + "get_wireless_scan_info": { + "ap_list": [ + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 0, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 0, + "key_type": "none", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + } + ], + "start_index": 0, + "sum": 25, + "wep_supported": false + }, + "qs_component_nego": { + "component_list": [ + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "ble_whole_setup", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "inherit", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + } + ], + "extra_info": { + "device_model": "P115", + "device_type": "SMART.TAPOPLUG", + "is_klap": true + } + } +}