Add child devices from hubs to generated list of supported devices (#898)

Updates generate_supported hook to include child devices of hubs in the list of supported devices.
This commit is contained in:
Steven B 2024-05-07 07:48:47 +01:00 committed by GitHub
parent c5d65b624b
commit f063c83378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 53 additions and 12 deletions

View File

@ -232,6 +232,7 @@ The following devices have been tested and confirmed as working. If your device
- **Bulbs**: KL110, KL120, KL125, KL130, KL135, KL50, KL60, LB110
- **Light Strips**: KL400L5, KL420L5, KL430
- **Hubs**: KH100<sup>\*</sup>
- **Hub-Connected Devices<sup>\*\*\*</sup>**: KE100<sup>\*</sup>
### Supported Tapo<sup>\*</sup> devices
@ -241,10 +242,12 @@ The following devices have been tested and confirmed as working. If your device
- **Bulbs**: L510B, L510E, L530E
- **Light Strips**: L900-10, L900-5, L920-5, L930-5
- **Hubs**: H100
- **Hub-Connected Devices<sup>\*\*\*</sup>**: T300, T310, T315
<!--SUPPORTED_END-->
<sup>*</sup>&nbsp; Model requires authentication<br>
<sup>**</sup> Newer versions require authentication
<sup>\*</sup>&nbsp;&nbsp; Model requires authentication<br>
<sup>\*\*</sup>&nbsp; Newer versions require authentication<br>
<sup>\*\*\*</sup> Devices may work across TAPO/KASA branded hubs
See [supported devices in our documentation](SUPPORTED.md) for more detailed information about tested hardware and software versions.

View File

@ -6,7 +6,7 @@ The following devices have been tested and confirmed as working. If your device
<!--SUPPORTED_START-->
## Kasa devices
Some newer Kasa devices require authentication. These are marked with <sup>*</sup> in the list below.
Some newer Kasa devices require authentication. These are marked with <sup>*</sup> in the list below.<br>Hub-Connected Devices may work across TAPO/KASA branded hubs even if they don't work across the native apps.
### Plugs
@ -134,10 +134,16 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
- **KH100**
- Hardware: 1.0 (UK) / Firmware: 1.5.6<sup>\*</sup>
### Hub-Connected Devices
- **KE100**
- Hardware: 1.0 (EU) / Firmware: 2.8.0<sup>\*</sup>
- Hardware: 1.0 (UK) / Firmware: 2.8.0<sup>\*</sup>
## Tapo devices
All Tapo devices require authentication.
All Tapo devices require authentication.<br>Hub-Connected Devices may work across TAPO/KASA branded hubs even if they don't work across the native apps.
### Plugs
@ -204,5 +210,14 @@ All Tapo devices require authentication.
- Hardware: 1.0 (EU) / Firmware: 1.2.3
- Hardware: 1.0 (EU) / Firmware: 1.5.5
### Hub-Connected Devices
- **T300**
- Hardware: 1.0 (EU) / Firmware: 1.7.0
- **T310**
- Hardware: 1.0 (EU) / Firmware: 1.5.0
- **T315**
- Hardware: 1.0 (EU) / Firmware: 1.7.0
<!--SUPPORTED_END-->

View File

@ -29,10 +29,12 @@ DEVICE_TYPE_TO_PRODUCT_GROUP = {
DeviceType.StripSocket: "Power Strips",
DeviceType.Dimmer: "Wall Switches",
DeviceType.WallSwitch: "Wall Switches",
DeviceType.Fan: "Wall Switches",
DeviceType.Bulb: "Bulbs",
DeviceType.LightStrip: "Light Strips",
DeviceType.Hub: "Hubs",
DeviceType.Sensor: "Sensors",
DeviceType.Sensor: "Hub-Connected Devices",
DeviceType.Thermostat: "Hub-Connected Devices",
}
@ -106,7 +108,7 @@ def _supported_summary(supported):
return _supported_text(
supported,
"### Supported $brand$auth devices\n\n$types\n",
"- **$type_**: $models\n",
"- **$type_$type_asterix**: $models\n",
)
@ -136,6 +138,10 @@ def _supported_text(
if brand == "kasa"
else "All Tapo devices require authentication."
)
preamble_text += (
"<br>Hub-Connected Devices may work across TAPO/KASA branded "
+ "hubs even if they don't work across the native apps."
)
brand_text = brand.capitalize()
brand_auth = r"<sup>\*</sup>" if brand == "tapo" else ""
types_text = ""
@ -177,7 +183,14 @@ def _supported_text(
else:
models_list.append(f"{model}{auth_flag}")
models_text = models_text if models_text else ", ".join(models_list)
types_text += typest.substitute(type_=supported_type, models=models_text)
type_asterix = (
r"<sup>\*\*\*</sup>"
if supported_type == "Hub-Connected Devices"
else ""
)
types_text += typest.substitute(
type_=supported_type, type_asterix=type_asterix, models=models_text
)
brands += brandt.substitute(
brand=brand_text, types=types_text, auth=brand_auth, preamble=preamble_text
)
@ -185,16 +198,22 @@ def _supported_text(
def _get_smart_supported(supported):
for file in Path(SMART_FOLDER).glob("*.json"):
for file in Path(SMART_FOLDER).glob("**/*.json"):
with file.open() as f:
fixture_data = json.load(f)
model, _, region = fixture_data["discovery_result"]["device_model"].partition(
"("
)
if "discovery_result" in fixture_data:
model, _, region = fixture_data["discovery_result"][
"device_model"
].partition("(")
device_type = fixture_data["discovery_result"]["device_type"]
else: # child devices of hubs do not have discovery result
model = fixture_data["get_device_info"]["model"]
region = fixture_data["get_device_info"].get("specs")
device_type = fixture_data["get_device_info"]["type"]
# P100 doesn't have region HW
region = region.replace(")", "") if region else ""
device_type = fixture_data["discovery_result"]["device_type"]
_protocol, devicetype = device_type.split(".")
brand = devicetype[:4].lower()
components = [

View File

@ -639,6 +639,10 @@ class SmartDevice(Bulb, Fan, Device):
return DeviceType.Bulb
if "SWITCH" in device_type:
return DeviceType.WallSwitch
if "SENSOR" in device_type:
return DeviceType.Sensor
if "ENERGY" in device_type:
return DeviceType.Thermostat
_LOGGER.warning("Unknown device type, falling back to plug")
return DeviceType.Plug