Exemplo n.º 1
0
def cli(ctx, mac, debug):
    """ A tool to query Yeelight bedside lamp. """
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        if debug > 1:
            btle.Debugging = True
        DEBUG = debug
    else:
        logging.basicConfig(level=logging.INFO)

    # if we are scanning, we do not try to connect.
    if ctx.invoked_subcommand == "scan":
        return

    if mac is None:
        logging.error("You have to specify MAC address to use either by setting YEELIGHTBT_MAC environment variable or passing --mac option!")
        sys.exit(1)

    lamp = Lamp(mac, notification_cb, paired_cb,
                keep_connection=True, wait_after_call=0.2)
    lamp.connect()
    lamp.state()
    ctx.obj = lamp

    if ctx.invoked_subcommand is None:
        ctx.invoke(state)
Exemplo n.º 2
0
def cli(ctx, mac, debug):
    """ A tool to query Yeelight bedside lamp. """
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        if debug > 1:
            btle.Debugging = True
        DEBUG = debug
    else:
        logging.basicConfig(level=logging.INFO)

    # if we are scanning, we do not try to connect.
    if ctx.invoked_subcommand == "scan":
        return

    lamp = Lamp(mac, notification_cb, paired_cb,
                keep_connection=True, wait_after_call=0.5)
    lamp.connect()
    lamp.state()
    ctx.obj = lamp

    if ctx.invoked_subcommand is None:
        ctx.invoke(state)