示例#1
0
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)}")
示例#2
0
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)}")
示例#3
0
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)}")
示例#4
0
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)}")
示例#5
0
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)}")
示例#6
0
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)}")