Make device initialisation easier by reducing required imports (#936)

Adds username and password arguments to discovery to remove the need to import Credentials.
Creates TypeAliases in Device for connection configuration classes and DeviceType.
Using the API with these changes will only require importing either Discover or Device
depending on whether using Discover.discover() or Device.connect() to 
initialize and interact with the API.
This commit is contained in:
Steven B
2024-06-03 21:06:54 +03:00
committed by GitHub
parent bfba7a347f
commit be5202ccb7
12 changed files with 263 additions and 90 deletions

View File

@@ -231,11 +231,11 @@ async def cli(
if host is not None:
if discovery_info:
click.echo("Host and discovery info given, trying connect on %s." % host)
from kasa import ConnectionType, DeviceConfig
from kasa import DeviceConfig, DeviceConnectionParameters
di = json.loads(discovery_info)
dr = DiscoveryResult(**di)
connection_type = ConnectionType.from_values(
connection_type = DeviceConnectionParameters.from_values(
dr.device_type,
dr.mgt_encrypt_schm.encrypt_type,
dr.mgt_encrypt_schm.lv,