homebridge-kasa-python 2.7.0-beta.22 → 2.7.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import asyncio, sys
2
2
  from typing import Any, Dict, List, Optional
3
3
 
4
- from kasa import AuthenticationError, Credentials, Device, DeviceType, Discover, Module, UnsupportedDeviceError
4
+ from kasa import AuthenticationError, Credentials, Device, DeviceType, DeviceConfig, Discover, Module, UnsupportedDeviceError
5
5
  from quart import Quart, jsonify, request
6
6
 
7
7
  app = Quart(__name__)
@@ -18,7 +18,7 @@ UNSUPPORTED_TYPES = {
18
18
 
19
19
  device_cache: Dict[str, Device] = {}
20
20
  device_locks: Dict[str, asyncio.Lock] = {}
21
- device_configs: Dict[str, Dict[str, Any]] = {}
21
+ device_configs: Dict[str, DeviceConfig] = {}
22
22
 
23
23
  def serialize_child(child: Device) -> Dict[str, Any]:
24
24
  print(f"Serializing child device {child.alias}")
@@ -81,25 +81,9 @@ def custom_serializer(device: Device) -> Dict[str, Any]:
81
81
  else:
82
82
  feature_info = {}
83
83
 
84
- device_config = {
85
- "host": device.config.host,
86
- "timeout": device.config.timeout,
87
- "uses_http": device.config.uses_http,
88
- **({"credentials": {
89
- "username": device.config.credentials.username,
90
- "password": device.config.credentials.password
91
- }} if device.config.credentials else {}),
92
- "connection_type": {
93
- "device_family": device.config.connection_type.device_family.value,
94
- "encryption_type": device.config.connection_type.encryption_type.value,
95
- "https": device.config.connection_type.https
96
- }
97
- }
98
-
99
84
  return {
100
85
  "sys_info": sys_info,
101
- "feature_info": feature_info,
102
- "device_config": device_config
86
+ "feature_info": feature_info
103
87
  }
104
88
 
105
89
  async def discover_devices(
@@ -217,7 +201,7 @@ async def close_all_connections():
217
201
  async def create_device_info(host: str, device: Device):
218
202
  print("Creating device info for host: ", host)
219
203
  device_info = custom_serializer(device)
220
- device_configs[host] = device_info["device_config"]
204
+ device_configs[host] = device.config.to_dict()
221
205
  all_device_info = {
222
206
  "sys_info": device_info["sys_info"],
223
207
  "feature_info": device_info["feature_info"],
@@ -257,7 +241,7 @@ async def control_device(
257
241
  device = await reconnect_device(host, device_config)
258
242
  return await perform_device_action(device, feature, action, value, child_num)
259
243
 
260
- async def get_or_connect_device(host: str, device_config: Dict[str, Any]) -> Device:
244
+ async def get_or_connect_device(host: str, device_config: DeviceConfig) -> Device:
261
245
  device = device_cache.get(host)
262
246
  if not device:
263
247
  print(f"Device not in cache, connecting to device at host: {host}")
@@ -265,7 +249,7 @@ async def get_or_connect_device(host: str, device_config: Dict[str, Any]) -> Dev
265
249
  device_cache[host] = device
266
250
  return device
267
251
 
268
- async def reconnect_device(host: str, device_config: Dict[str, Any]) -> Device:
252
+ async def reconnect_device(host: str, device_config: DeviceConfig) -> Device:
269
253
  device = device_cache.pop(host, None)
270
254
  if device:
271
255
  await device.disconnect()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge Kasa Python",
3
3
  "name": "homebridge-kasa-python",
4
- "version": "2.7.0-beta.22",
4
+ "version": "2.7.0-beta.23",
5
5
  "description": "Plugin that uses Python-Kasa API to communicate with Kasa Devices.",
6
6
  "license": "MIT",
7
7
  "type": "module",