switchbot/__init__.py
def factory(switchbot, id, group=True):
        """Return device object of correct type."""
        device, _ = Device._query_device(switchbot, sanitize_id(id))

        type = device["device_detail"]["device_type"]
        links = []

        if "deviceLinks" in device:
            links = device["deviceLinks"]

        assert type is not None

        if type == "WoLinkMini":
            return MiniHub(switchbot, id)
        elif type == "WoHand":
            return Bot(switchbot, id)
        elif type == "WoCurtain":
            if links and group:
                return CurtainGroup(switchbot, links[0])
            else:
                return Curtain(switchbot, id)
        else:
            return Device(switchbot, id)
Return device object of correct type.
Return device object of correct type.
Return device object of correct type .
def factory(switchbot, id, group=True):
        device, _ = Device._query_device(switchbot, sanitize_id(id))
        type = device["device_detail"]["device_type"]
        links = []
        if "deviceLinks" in device:
            links = device["deviceLinks"]
        assert type is not None
        if type == "WoLinkMini":
            return MiniHub(switchbot, id)
        elif type == "WoHand":
            return Bot(switchbot, id)
        elif type == "WoCurtain":
            if links and group:
                return CurtainGroup(switchbot, links[0])
            else:
                return Curtain(switchbot, id)
        else:
            return Device(switchbot, id)
def factory ( switchbot , id , group = True ) : device , _ = Device . _query_device ( switchbot , sanitize_id ( id ) ) type = device [ "device_detail" ] [ "device_type" ] links = [ ] if "deviceLinks" in device : links = device [ "deviceLinks" ] assert type is not None if type == "WoLinkMini" : return MiniHub ( switchbot , id ) elif type == "WoHand" : return Bot ( switchbot , id ) elif type == "WoCurtain" : if links and group : return CurtainGroup ( switchbot , links [ 0 ] ) else : return Curtain ( switchbot , id ) else : return Device ( switchbot , id )
Return device object of correct type.
Return device object of correct type .
"""Return device object of correct type."""
switchbot
id
group