def check_and_create_device(self, info, addr) -> Optional[Device]:
"""Create a corresponding :class:`Device` implementation
for a given info and address.."""
name = info.name
for identifier, v in DEVICE_MAP.items():
if name.startswith(identifier):
if inspect.isclass(v):
_LOGGER.debug("Found a supported '%s', using '%s' class",
name, v.__name__)
return create_device(addr, v)
elif callable(v):
dev = Device(ip=addr)
_LOGGER.info("%s: token: %s",
v(info),
pretty_token(dev.do_discover().checksum))
return None
_LOGGER.warning("Found unsupported device %s at %s, "
"please report to developers", name, addr)
return None
评论列表
文章目录