Skip to content

Commit

Permalink
Adds get_bluetooth_devices to CLI (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored and eliseomartelli committed Nov 30, 2018
1 parent 582a0e7 commit cce9c3f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions googledevices/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ async def get_device_info():
LOOP.run_until_complete(get_device_info())


@commands.command()
@click.argument('ip_address', required=1)
def get_bluetooth_devices(ip_address):
"""Get bluetooth devices from a unit."""
from googledevices.api.bluetooth import Bluetooth

async def bluetooth_scan():
"""Get nearby bluetooth devices."""
async with aiohttp.ClientSession() as session:
googledevices = Bluetooth(LOOP, session, ip_address)
await googledevices.scan_for_devices()
await googledevices.get_scan_result()
print(json.dumps(googledevices.devices, indent=4, sort_keys=True))
LOOP.run_until_complete(bluetooth_scan())


@commands.command()
@click.option('--subnet', type=str, default=None, help="Format 0.0.0.0/00")
def get_all_devices(subnet):
Expand Down

0 comments on commit cce9c3f

Please # to comment.