Skip to content

Commit b3c8a08

Browse files
committed
Fix silent dropping of plugs...hopefully...
1 parent f664b8d commit b3c8a08

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/powersensor_local/zeroconf_devices.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,20 @@ def _extract(self, zc: Any, type_: str, name: str) -> tuple[str, str, int] | Non
312312
return None
313313

314314
try:
315-
mac = info.properties[b'id'].decode('utf-8')
316-
except (KeyError, AttributeError) as err:
317-
_LOGGER.error(
318-
"Missing 'id' property in zeroconf record for %s: %s", name, err
319-
)
315+
raw_id = info.properties[b'id']
316+
except KeyError:
317+
_LOGGER.error("Missing 'id' property in zeroconf record for %s", name)
318+
return None
319+
320+
if raw_id is None:
321+
_LOGGER.error("'id' property in zeroconf record for %s has no value", name)
322+
return None
323+
324+
if info.port is None:
325+
_LOGGER.error("No port in zeroconf record for %s", name)
320326
return None
321327

322-
return mac, addresses[0], info.port
328+
return raw_id.decode('utf-8'), addresses[0], info.port
323329

324330
def add_service(self, zc: Any, type_: str, name: str) -> None:
325331
result = self._extract(zc, type_, name)

0 commit comments

Comments
 (0)