Skip to content

Bridge 🔗

Bridge(*, ip: str, user: str) -> Bridge

Interact with the Hue Bridge API

Examples:

>>> from hue import Bridge
>>> bridge = Bridge(ip="192.168.1.10", user="xxxx")
>>> print(bridge.url)
http://192.168.1.10/api/xxxx

Attributes:

Name Type Description
ip str

IP address of the Hue Bridge

user str

The secret user id used to access the Hue API

info dict[str, Any]

The last Bridge information stored in the object by calling get_info() or get_config()

Initialize a Hue Bridge object

Parameters:

Name Type Description Default
ip str

IP address of the Hue Bridge, get it by running hue bridge discover

required
user str

The secret user id created to access the Hue API

required

Returns:

Type Description
Bridge

An object of class Bridge

Source code in hue/api/bridge.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def __init__(self: Bridge, *, ip: str, user: str) -> Bridge:
    """
    Initialize a Hue Bridge object

    Arguments:
        ip: IP address of the Hue Bridge, get it by running `hue bridge discover`
        user: The secret user id created to access the Hue API

    Returns:
        An object of class Bridge
    """
    self.ip: str = ip
    self.user: str = user
    self.info: dict[str, Any] = {}

Functions🔗

discover async staticmethod 🔗

discover() -> list[dict[str, str]]

Discover Hue Bridges available in this local network

Returns:

Type Description
list[dict[str, str]]

A list of Hue Bridges discovered in the local network

Source code in hue/api/bridge.py
49
50
51
52
53
54
55
56
57
@staticmethod
async def discover() -> list[dict[str, str]]:
    """
    Discover Hue Bridges available in this local network

    Returns:
        A list of Hue Bridges discovered in the local network
    """
    return await http.get_json("https://discovery.meethue.com/")

get_config async 🔗

get_config() -> dict[str, Any]

Get the current config of the Bridge

Returns:

Type Description
dict[str, Any]

A dictionary of the configuration of the Hue Bridge

Source code in hue/api/bridge.py
69
70
71
72
73
74
75
76
77
async def get_config(self) -> dict[str, Any]:
    """
    Get the current config of the Bridge

    Returns:
        A dictionary of the configuration of the Hue Bridge
    """
    resp = await self.get_info()
    return resp["config"]

get_info async 🔗

get_info() -> dict[str, Any]

List all the information about the Hue Bridge

Returns:

Type Description
dict[str, Any]

A dictionary of all the information about the Hue Bridge

Source code in hue/api/bridge.py
59
60
61
62
63
64
65
66
67
async def get_info(self) -> dict[str, Any]:
    """
    List all the information about the Hue Bridge

    Returns:
        A dictionary of all the information about the Hue Bridge
    """
    self.info = await http.get_json(self.url)
    return self.info

url property 🔗

url() -> str

Returns the Hue Bridge URL

Source code in hue/api/bridge.py
44
45
46
47
@property
def url(self) -> str:
    """Returns the Hue Bridge URL"""
    return f"http://{self.ip}/api/{self.user}"