homebridge-kasa-python 2.5.2 → 2.5.4

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.
@@ -67,14 +67,24 @@ async def discover_devices(username=None, password=None, additional_broadcasts=N
67
67
 
68
68
  if manual_devices:
69
69
  for host in manual_devices:
70
- await discover_manual_device(host, username, password, devices)
70
+ try:
71
+ app.logger.debug(f"Discovering manual device: {host}")
72
+ discovered_device = await Discover.discover_single(host=host, username=username, password=password)
73
+ if discovered_device and hasattr(discovered_device, 'device_type'):
74
+ devices[host] = discovered_device
75
+ app.logger.debug(f"Discovered manual device: {host}")
76
+ else:
77
+ app.logger.warning(f"Manual device not found or missing device_type: {host}")
78
+ except Exception as e:
79
+ app.logger.error(f"Error discovering manual device {host}: {str(e)}")
71
80
 
72
81
  all_device_info = {}
73
82
  tasks = []
74
83
 
75
84
  for ip, dev in devices.items():
76
85
  try:
77
- if hasattr(dev, 'device_type') and dev.sys_info['mic_type'] not in UNSUPPORTED_TYPES:
86
+ dev_type = dev.sys_info.get("mic_type") or dev.sys_info.get("type")
87
+ if hasattr(dev, 'device_type') and (dev_type and dev_type not in UNSUPPORTED_TYPES):
78
88
  tasks.append(update_device_info(ip, dev))
79
89
  except KeyError:
80
90
  continue
@@ -91,25 +101,6 @@ async def discover_devices(username=None, password=None, additional_broadcasts=N
91
101
  app.logger.debug(f"Device discovery completed with {len(all_device_info)} devices found")
92
102
  return all_device_info
93
103
 
94
- async def discover_manual_device(host, username, password, devices, retries=3, timeout=5):
95
- for attempt in range(retries):
96
- try:
97
- app.logger.debug(f"Discovering manual device: {host} (Attempt {attempt + 1}/{retries})")
98
- discovered_device = await Discover.discover_single(host=host, username=username, password=password, discovery_timeout=timeout)
99
- if discovered_device and hasattr(discovered_device, 'device_type'):
100
- devices[host] = discovered_device
101
- app.logger.debug(f"Discovered manual device: {host}")
102
- return
103
- else:
104
- app.logger.warning(f"Manual device not found or missing device_type: {host}")
105
- except Exception as e:
106
- app.logger.error(f"Error discovering manual device {host}: {str(e)}")
107
- if attempt < retries - 1:
108
- app.logger.debug(f"Retrying discovery for manual device: {host}")
109
- await asyncio.sleep(1)
110
- else:
111
- app.logger.error(f"Failed to discover manual device {host} after {retries} attempts")
112
-
113
104
  async def update_device_info(ip, dev: Device):
114
105
  app.logger.debug(f"Updating device info for {ip}")
115
106
  try:
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.5.2",
4
+ "version": "2.5.4",
5
5
  "description": "Plugin that uses Python-Kasa API to communicate with Kasa Devices.",
6
6
  "license": "MIT",
7
7
  "type": "module",