discovery.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:python-miio 作者: rytilahti 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号