Light 🔗
Light(id: int, *, ip: str, user: str) -> Light
Bases: Bridge
Interact with the Hue Lights API
Examples:
>>> from hue import Light
>>> light = Light(1, ip="192.168.1.10", user="xxxx")
>>> print(light.url)
http://192.168.1.10/api/xxxx/lights/1
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
ID of the Hue Light |
ip |
str
|
IP address of the Hue Bridge |
user |
str
|
The secret user id used to access the Hue API |
on |
bool
|
The last saved power state of the Light, saved by calling any light operation from the object |
state |
dict[str, Any]
|
The last saved Light state stored in the object saved by calling any light operation from the object |
saved_state |
dict[str, Any]
|
The Light state stored in the object by calling |
info |
dict[str, Any]
|
The last saved Light information stored in the object by calling |
Initialize a Hue Light object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
int
|
The ID (number) of the Light to control |
required |
ip |
str
|
IP address of the Hue Bridge, get it by running |
required |
user |
str
|
The secret user id created to access the Hue API |
required |
Returns:
Type | Description |
---|---|
Light
|
An object of class Light |
Source code in hue/api/light.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
Functions🔗
get_info
async
🔗
get_info() -> dict[str, Any]
List all the information about a Hue Light
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary of all the information about the Hue Light |
Source code in hue/api/light.py
63 64 65 66 67 68 69 70 71 |
|
get_state
async
🔗
get_state() -> dict[str, Any]
Get the current state of the Light
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary of the current state of the Hue Light |
Source code in hue/api/light.py
73 74 75 76 77 78 79 80 81 82 83 |
|
power_off
async
🔗
power_off() -> list[dict[str, dict[str, Any]]]
Power off the Light
Returns:
Type | Description |
---|---|
list[dict[str, dict[str, Any]]]
|
A list of dictionaries with key=success/error and value=state element changed |
Source code in hue/api/light.py
165 166 167 168 169 170 171 172 |
|
power_on
async
🔗
power_on() -> list[dict[str, dict[str, Any]]]
Power on the Light
Returns:
Type | Description |
---|---|
list[dict[str, dict[str, Any]]]
|
A list of dictionaries with key=success/error and value=state element changed |
Source code in hue/api/light.py
156 157 158 159 160 161 162 163 |
|
restore_state
async
🔗
restore_state() -> list[dict[str, dict[str, Any]]]
Restore the saved state (set by calling save_state()
) of the Light
Returns:
Type | Description |
---|---|
list[dict[str, dict[str, Any]]]
|
A list of dictionaries with key=success/error and value=state element changed |
Source code in hue/api/light.py
146 147 148 149 150 151 152 153 154 |
|
save_state
async
🔗
save_state() -> dict[str, Any]
Save the current state of the Light in the object
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary of the current state of the Light that will be saved |
Source code in hue/api/light.py
136 137 138 139 140 141 142 143 144 |
|
set_state
async
🔗
set_state(state: dict[str, Any]) -> list[dict[str, dict[str, Any]]]
Set the state of the Light. See this link for details
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
dict[str, Any]
|
The state to set the light to, it may consist of the following keys:
|
required |
Returns:
Type | Description |
---|---|
list[dict[str, dict[str, Any]]]
|
A list of dictionaries with key=success/error and value=state element changed |
Source code in hue/api/light.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
toggle
async
🔗
toggle() -> list[dict[str, dict[str, Any]]]
Toggle the power state of the Light
Returns:
Type | Description |
---|---|
list[dict[str, dict[str, Any]]]
|
A list of dictionaries with key=success/error and value=state element changed |
Source code in hue/api/light.py
174 175 176 177 178 179 180 181 182 |
|
url
property
🔗
url() -> str
Returns the Hue Light URL
Source code in hue/api/light.py
58 59 60 61 |
|