def _dev(self): from yeelightbt import Lamp if not self.__dev: _LOGGER.error("Initializing %s", self._mac) self.__dev = Lamp(self._mac, self._status_cb, keep_connection=True) return self.__dev
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)
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)
def sleep(dev: Lamp, time): dev.get_sleep()