FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add child devices from hubs to generated list of supported devices (#… · python-kasa/python-kasa@f063c83 · GitHub

Repository navigation

Commit f063c83

Browse files
authored
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.
1 parent c5d65b6 commit f063c83

4 files changed

Lines changed: 53 additions & 12 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ The following devices have been tested and confirmed as working. If your device
232232
- **Bulbs**: KL110, KL120, KL125, KL130, KL135, KL50, KL60, LB110
233233
- **Light Strips**: KL400L5, KL420L5, KL430
234234
- **Hubs**: KH100<sup>\*</sup>
235+
- **Hub-Connected Devices<sup>\*\*\*</sup>**: KE100<sup>\*</sup>
235236

236237
### Supported Tapo<sup>\*</sup> devices
237238

@@ -241,10 +242,12 @@ The following devices have been tested and confirmed as working. If your device
241242
- **Bulbs**: L510B, L510E, L530E
242243
- **Light Strips**: L900-10, L900-5, L920-5, L930-5
243244
- **Hubs**: H100
245+
- **Hub-Connected Devices<sup>\*\*\*</sup>**: T300, T310, T315
244246

245247
<!--SUPPORTED_END-->
246-
<sup>*</sup>&nbsp; Model requires authentication<br>
247-
<sup>**</sup> Newer versions require authentication
248+
<sup>\*</sup>&nbsp;&nbsp; Model requires authentication<br>
249+
<sup>\*\*</sup>&nbsp; Newer versions require authentication<br>
250+
<sup>\*\*\*</sup> Devices may work across TAPO/KASA branded hubs
248251

249252
See [supported devices in our documentation](SUPPORTED.md) for more detailed information about tested hardware and software versions.
250253

‎SUPPORTED.md‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The following devices have been tested and confirmed as working. If your device
66
<!--SUPPORTED_START-->
77
## Kasa devices
88

9-
Some newer Kasa devices require authentication. These are marked with <sup>*</sup> in the list below.
9+
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.
1010

1111
### Plugs
1212

@@ -134,10 +134,16 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
134134
- **KH100**
135135
- Hardware: 1.0 (UK) / Firmware: 1.5.6<sup>\*</sup>
136136

137+
### Hub-Connected Devices
138+
139+
- **KE100**
140+
- Hardware: 1.0 (EU) / Firmware: 2.8.0<sup>\*</sup>
141+
- Hardware: 1.0 (UK) / Firmware: 2.8.0<sup>\*</sup>
142+
137143

138144
## Tapo devices
139145

140-
All Tapo devices require authentication.
146+
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.
141147

142148
### Plugs
143149

@@ -204,5 +210,14 @@ All Tapo devices require authentication.
204210
- Hardware: 1.0 (EU) / Firmware: 1.2.3
205211
- Hardware: 1.0 (EU) / Firmware: 1.5.5
206212

213+
### Hub-Connected Devices
214+
215+
- **T300**
216+
- Hardware: 1.0 (EU) / Firmware: 1.7.0
217+
- **T310**
218+
- Hardware: 1.0 (EU) / Firmware: 1.5.0
219+
- **T315**
220+
- Hardware: 1.0 (EU) / Firmware: 1.7.0
221+
207222

208223
<!--SUPPORTED_END-->

‎devtools/generate_supported.py‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ class SupportedVersion(NamedTuple):
2929
DeviceType.StripSocket: "Power Strips",
3030
DeviceType.Dimmer: "Wall Switches",
3131
DeviceType.WallSwitch: "Wall Switches",
32+
DeviceType.Fan: "Wall Switches",
3233
DeviceType.Bulb: "Bulbs",
3334
DeviceType.LightStrip: "Light Strips",
3435
DeviceType.Hub: "Hubs",
35-
DeviceType.Sensor: "Sensors",
36+
DeviceType.Sensor: "Hub-Connected Devices",
37+
DeviceType.Thermostat: "Hub-Connected Devices",
3638
}
3739

3840

@@ -106,7 +108,7 @@ def _supported_summary(supported):
106108
return _supported_text(
107109
supported,
108110
"### Supported $brand$auth devices\n\n$types\n",
109-
"- **$type_**: $models\n",
111+
"- **$type_$type_asterix**: $models\n",
110112
)
111113

112114

@@ -136,6 +138,10 @@ def _supported_text(
136138
if brand == "kasa"
137139
else "All Tapo devices require authentication."
138140
)
141+
preamble_text += (
142+
"<br>Hub-Connected Devices may work across TAPO/KASA branded "
143+
+ "hubs even if they don't work across the native apps."
144+
)
139145
brand_text = brand.capitalize()
140146
brand_auth = r"<sup>\*</sup>" if brand == "tapo" else ""
141147
types_text = ""
@@ -177,24 +183,37 @@ def _supported_text(
177183
else:
178184
models_list.append(f"{model}{auth_flag}")
179185
models_text = models_text if models_text else ", ".join(models_list)
180-
types_text += typest.substitute(type_=supported_type, models=models_text)
186+
type_asterix = (
187+
r"<sup>\*\*\*</sup>"
188+
if supported_type == "Hub-Connected Devices"
189+
else ""
190+
)
191+
types_text += typest.substitute(
192+
type_=supported_type, type_asterix=type_asterix, models=models_text
193+
)
181194
brands += brandt.substitute(
182195
brand=brand_text, types=types_text, auth=brand_auth, preamble=preamble_text
183196
)
184197
return brands
185198

186199

187200
def _get_smart_supported(supported):
188-
for file in Path(SMART_FOLDER).glob("*.json"):
201+
for file in Path(SMART_FOLDER).glob("**/*.json"):
189202
with file.open() as f:
190203
fixture_data = json.load(f)
191204

192-
model, _, region = fixture_data["discovery_result"]["device_model"].partition(
193-
"("
194-
)
205+
if "discovery_result" in fixture_data:
206+
model, _, region = fixture_data["discovery_result"][
207+
"device_model"
208+
].partition("(")
209+
device_type = fixture_data["discovery_result"]["device_type"]
210+
else: # child devices of hubs do not have discovery result
211+
model = fixture_data["get_device_info"]["model"]
212+
region = fixture_data["get_device_info"].get("specs")
213+
device_type = fixture_data["get_device_info"]["type"]
195214
# P100 doesn't have region HW
196215
region = region.replace(")", "") if region else ""
197-
device_type = fixture_data["discovery_result"]["device_type"]
216+
198217
_protocol, devicetype = device_type.split(".")
199218
brand = devicetype[:4].lower()
200219
components = [

‎kasa/smart/smartdevice.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ def _get_device_type_from_components(
639639
return DeviceType.Bulb
640640
if "SWITCH" in device_type:
641641
return DeviceType.WallSwitch
642+
if "SENSOR" in device_type:
643+
return DeviceType.Sensor
644+
if "ENERGY" in device_type:
645+
return DeviceType.Thermostat
642646
_LOGGER.warning("Unknown device type, falling back to plug")
643647
return DeviceType.Plug
644648

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL