homebridge-kasa-python 2.1.1 → 2.1.3

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.
@@ -16,37 +16,62 @@ def custom_device_serializer(device):
16
16
  except TypeError:
17
17
  return False
18
18
 
19
- return {attr: getattr(device, attr) for attr in dir(device)
20
- if not attr.startswith("_") and not callable(getattr(device, attr))
21
- and not asyncio.iscoroutine(getattr(device, attr))
22
- and is_serializable(getattr(device, attr))}
19
+ serialized_data = {}
20
+ for attr in dir(device):
21
+ if not attr.startswith("_") and not callable(getattr(device, attr)) and not asyncio.iscoroutine(getattr(device, attr)):
22
+ value = getattr(device, attr)
23
+ if is_serializable(value):
24
+ serialized_data[attr] = value
25
+ else:
26
+ app.logger.debug(f"Skipping non-serializable attribute: {attr} with value: {value}")
27
+ app.logger.debug(f"Serialized data for device: {serialized_data}")
28
+ return serialized_data
23
29
 
24
30
  async def discover_devices():
25
31
  app.logger.debug('Starting device discovery...')
26
- devices = await Discover.discover()
27
- app.logger.debug(f'Discovered devices: {devices}')
32
+ try:
33
+ devices = await Discover.discover()
34
+ app.logger.debug(f'Discovered devices: {devices}')
35
+ except Exception as e:
36
+ app.logger.error(f'Error during device discovery: {str(e)}')
37
+ return {}
38
+
28
39
  all_device_info = {}
29
40
  tasks = []
30
41
  for ip, dev in devices.items():
31
- app.logger.debug(f'Creating update task for device at {ip}')
42
+ app.logger.debug(f'Creating update task for device at {ip} with device: {dev}')
32
43
  tasks.append(update_device_info(ip, dev))
33
- results = await asyncio.gather(*tasks)
44
+
45
+ try:
46
+ results = await asyncio.gather(*tasks)
47
+ app.logger.debug(f'Update tasks completed with results: {results}')
48
+ except Exception as e:
49
+ app.logger.error(f'Error during update tasks: {str(e)}')
50
+ return {}
51
+
34
52
  for ip, info in results:
35
53
  all_device_info[ip] = info
54
+ app.logger.debug(f'Updated device info for {ip}: {info}')
55
+
36
56
  app.logger.debug(f'All device info: {all_device_info}')
37
57
  return all_device_info
38
58
 
39
59
  async def update_device_info(ip, dev: Device):
40
60
  app.logger.debug(f'Updating device info for {ip}')
41
- await dev.update()
42
- device_info = custom_device_serializer(dev)
43
- device_config = dev.config.to_dict()
44
- device_cache[ip] = {
45
- "device_info": device_info,
46
- "device_config": device_config
47
- }
48
- app.logger.debug(f'Updated device info for {ip}: {device_cache[ip]}')
49
- return ip, device_cache[ip]
61
+ try:
62
+ await dev.update()
63
+ app.logger.debug(f'Device updated for {ip}: {dev}')
64
+ device_info = custom_device_serializer(dev)
65
+ device_config = dev.config.to_dict()
66
+ device_cache[ip] = {
67
+ "device_info": device_info,
68
+ "device_config": device_config
69
+ }
70
+ app.logger.debug(f'Updated device info for {ip}: {device_cache[ip]}')
71
+ return ip, device_cache[ip]
72
+ except Exception as e:
73
+ app.logger.error(f'Error updating device info for {ip}: {str(e)}')
74
+ return ip, {}
50
75
 
51
76
  async def get_device_info(device_config):
52
77
  app.logger.debug(f'Getting device info for config: {device_config}')
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.1.1",
4
+ "version": "2.1.3",
5
5
  "description": "Plugin that uses Python-Kasa API to communicate with Kasa Devices.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/ZeliardM/homebridge-kasa-python/issues"
14
14
  },
15
15
  "engines": {
16
- "node": "^18.20.4 || ^20.18.0 || ^22.10.0 || ^23.1.0",
16
+ "node": "^18.20.4 || ^20.18.0 || ^22.11.0 || ^23.1.0",
17
17
  "homebridge": "^1.8.0 || ^2.0.0-beta.0",
18
18
  "python": "^3.9.0"
19
19
  },
package/requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
1
  eventlet==0.37.0
2
2
  flask==3.0.3
3
3
  flask_socketio==5.4.1
4
- python-kasa==0.7.6
4
+ python-kasa==0.7.7