def get( ip: str = typer.Option(..., "--ip", "-i", envvar="HUE_BRIDGE_IP"), user: str = typer.Option(..., "--user", "-u", envvar="HUE_BRIDGE_USER"), ): """Get the config of a Bridge""" bridge = Bridge(ip=ip, user=user) resp = asyncio.run(bridge.get_config()) console.print(f"[{ip}] Bridge Config:\n{json.dumps(resp, indent=2)}")
def info( ip: str = typer.Option(..., "--ip", "-i", envvar="HUE_BRIDGE_IP"), user: str = typer.Option(..., "--user", "-u", envvar="HUE_BRIDGE_USER"), ): """List all the information about a Hue Bridge""" bridge = Bridge(ip=ip, user=user) resp = asyncio.run(bridge.get_info()) console.print(f"[{ip}] Bridge Info:\n{json.dumps(resp, indent=2)}")
def toggle( id: int = typer.Argument(1), ip: str = typer.Option(..., "--ip", "-i", envvar="HUE_BRIDGE_IP"), user: str = typer.Option(..., "--user", "-u", envvar="HUE_BRIDGE_USER"), ): """Toggle the power state of a light""" light = Light(id, ip=ip, user=user) resp = asyncio.run(light.toggle()) console.print(f"[{ip}] Light {id} Toggle:\n{json.dumps(resp, indent=2)}")
def off( id: int = typer.Argument(1), ip: str = typer.Option(..., "--ip", "-i", envvar="HUE_BRIDGE_IP"), user: str = typer.Option(..., "--user", "-u", envvar="HUE_BRIDGE_USER"), ): """Power off a light""" light = Light(id, ip=ip, user=user) resp = asyncio.run(light.power_off()) console.print(f"[{ip}] Light {id} Off:\n{json.dumps(resp, indent=2)}")
def info( id: int = typer.Argument(1), ip: str = typer.Option(..., "--ip", "-i", envvar="HUE_BRIDGE_IP"), user: str = typer.Option(..., "--user", "-u", envvar="HUE_BRIDGE_USER"), ): """List all the information about a Hue Light""" light = Light(id, ip=ip, user=user) resp = asyncio.run(light.get_info()) console.print(f"[{ip}] Light {id}:\n{json.dumps(resp, indent=2)}")
def discover(): """Discover online Bridges in the local network""" resp = asyncio.run(Bridge.discover()) console.print(f"Hue Bridges Discovered:\n{json.dumps(resp, indent=2)}")