Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vladsternbach committed Oct 20, 2023
1 parent d697b62 commit c998b48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions yeelightble/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ def scan(timeout):
def state(dev: Lamp):
""" Requests the state from the device. """
dev.get_state()
wait_for_result_and_exit()


@pass_dev
def wait_for_result_and_exit(dev: Lamp):
dev.wait_for_notifications()
click.echo("MAC: %s" % dev.mac)
click.echo("State: %s" % dev.state)
sys.exit()


@cli.command()
Expand Down Expand Up @@ -141,7 +147,7 @@ def temperature(dev: Lamp, temperature, brightness):
@pass_dev
def name(dev: Lamp):
dev.get_name()
dev.wait_for_notifications()
wait_for_result_and_exit()


@cli.command(name="info")
Expand All @@ -150,14 +156,7 @@ def device_info(dev: Lamp):
"""Returns hw & sw version."""
dev.get_version_info()
dev.get_serial_number()
dev.wait_for_notifications()


@cli.command()
@pass_dev
def wait_for_notifications(dev: Lamp):
"""Wait for notifications."""
dev.wait_for_notifications()
wait_for_result_and_exit()


@cli.command(name="time")
Expand Down
4 changes: 2 additions & 2 deletions yeelightble/lamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def update(self, data):
logger.error('failed to connect after 3 tries')
logger.error('failed to update after 2 tries')

def wait_for_notifications(self):
def wait_for_notifications(self, seconds=3):
while True:
self._dev.wait(1)
self._dev.wait(seconds)

@property
def mac(self):
Expand Down
2 changes: 1 addition & 1 deletion yeelightble/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.6"
__version__ = "0.1.7"

0 comments on commit c998b48

Please sign in to comment.