@@ -137,6 +137,10 @@ class Discover:
137
137
138
138
DISCOVERY_QUERY = {
139
139
"system" : {"get_sysinfo" : None },
140
+ }
141
+
142
+ COMPLETE_DISCOVERY_QUERY = {
143
+ "system" : {"get_sysinfo" : None },
140
144
"emeter" : {"get_realtime" : None },
141
145
"smartlife.iot.dimmer" : {"get_dimmer_parameters" : None },
142
146
"smartlife.iot.common.emeter" : {"get_realtime" : None },
@@ -198,16 +202,20 @@ async def discover(
198
202
return protocol .discovered_devices
199
203
200
204
@staticmethod
201
- async def discover_single (host : str ) -> SmartDevice :
205
+ async def discover_single (host : str , complete : bool ) -> SmartDevice :
202
206
"""Discover a single device by the given IP address.
203
207
204
208
:param host: Hostname of device to query
209
+ :param complete: Whether to discover only with get_sysinfo or all options
205
210
:rtype: SmartDevice
206
211
:return: Object for querying/controlling found device.
207
212
"""
208
213
protocol = TPLinkSmartHomeProtocol ()
209
214
210
- info = await protocol .query (host , Discover .DISCOVERY_QUERY )
215
+ if complete :
216
+ info = await protocol .query (host , Discover .COMPLETE_DISCOVERY_QUERY )
217
+ else :
218
+ info = await protocol .query (host , Discover .DISCOVERY_QUERY )
211
219
212
220
device_class = Discover ._get_device_class (info )
213
221
if device_class is not None :
@@ -231,10 +239,7 @@ def _get_device_class(info: dict) -> Type[SmartDevice]:
231
239
else :
232
240
raise SmartDeviceException ("No 'system' nor 'get_sysinfo' in response" )
233
241
234
- if (
235
- "smartlife.iot.dimmer" in info
236
- and "get_dimmer_parameters" in info ["smartlife.iot.dimmer" ]
237
- ):
242
+ if "Dimmer" in sysinfo ["dev_name" ]:
238
243
return SmartDimmer
239
244
240
245
elif "smartplug" in type_ .lower () and "children" in sysinfo :
0 commit comments