Binary encoding and decoding of Zigbee messages for Hue lights
Project description
hue-zigbee-encoding
hue-zigbee-encoding implements encoding and decoding of the binary format used
by Philips Hue Zigbee devices.
The format was reverse-engineered by Christian Iversen and described at: https://github.com/chrivers/bifrost/blob/master/doc/hue-zigbee-format.md
Other related resources:
Installation
With pip: pip install hue-zigbee-encoding
With uv: uv add hue-zigbee-encoding
Documentation
HueLightUpdateMessage
The HueLightUpdateMessage class represents multiple attributes of a Hue light,
combined into one object. It supports conversion to and from bytes:
from hue_zigbee_encoding import HueLightUpdateMessage
# Convert to bytes: returns b"\x03\x00\x01\x7f"
HueLightUpdateMessage(is_on=True, brightness=127).to_bytes()
# Convert from bytes: returns a HueLightUpdateMessage object
HueLightUpdateMessage.from_bytes(b"\x03\x00\x01\x7f")
Use hex and fromhex to convert to and from printable strings:
# Convert to a hex string: returns "0300017f"
HueLightUpdateMessage(is_on=True, brightness=127).to_bytes().hex()
# Convert from a hex string: returns a HueLightUpdateMessage object
HueLightUpdateMessage.from_bytes(bytes.fromhex("0300017f"))
HueLightUpdateMessage attributes
All attributes are optional (they accept a value of None). You can apply
a subset of attributes to change only those settings of Hue lights.
| Attribute | Type | Description |
|---|---|---|
is_on |
bool | None |
Set to True to turn the light on, False to turn off. |
brightness |
int | None |
0–255 (0xFF), although only values 1 (dimmest) through 254 (brightest) are valid. |
color_temp |
HueLightColorMired | None |
Color temperature in mireds. You can also use HueLightColorMired.from_kelvin() to convert from Kelvin. |
color_xy |
HueLightColorXY | None |
Color as XY values. See also: https://viereck.ch/hue-xy-rgb/ |
transition_time |
int | None |
0–65535 (0xFFFF). Use 0 for an instantaneous transition, higher numbers for a slower fade. |
effect |
HueLightEffect | None |
Specify one of the light effects from the HueLightEffect enum. |
effect_speed |
int | None |
Animation speed of the selected effect: 0 (slowest) to 255 (fastest). |
gradient |
HueLightGradient | None |
Gradient colors and style (for light strips). |
gradient_params |
HueLightGradientParams | None |
Gradient scale and offset parameters (for light strips). |
HueLightColorXY
Color specified as XY coordinates in the range 0–1. See also: https://viereck.ch/hue-xy-rgb/
from hue_zigbee_encoding import HueLightColorXY
HueLightColorXY(x=0.424, y=0.285)
HueLightColorMired
Color temperature specified in mireds.
from hue_zigbee_encoding import HueLightColorMired
# Specify a color temperature in mireds:
HueLightColorMired(mired=40)
# Specify a color temperature in Kelvin:
HueLightColorMired.from_kelvin(25000)
HueLightEffect
This enum describes the predefined effects supported by Hue lights.
| Name | Decimal value | Hex value |
|---|---|---|
HueLightEffect.CANDLE |
1 | 0x01 |
HueLightEffect.FIREPLACE |
2 | 0x02 |
HueLightEffect.PRISM |
3 | 0x03 |
HueLightEffect.SUNRISE |
9 | 0x09 |
HueLightEffect.SPARKLE |
10 | 0x0A |
HueLightEffect.OPAL |
11 | 0x0B |
HueLightEffect.GLISTEN |
12 | 0x0C |
HueLightEffect.SUNSET |
13 | 0x0D |
HueLightEffect.UNDERWATER |
14 | 0x0E |
HueLightEffect.COSMOS |
15 | 0x0F |
HueLightEffect.SUNBEAM |
16 | 0x10 |
HueLightEffect.ENCHANT |
17 | 0x11 |
HueLightGradient
This class represents a custom gradient on a light strip.
from hue_zigbee_encoding import HueLightGradient
HueLightGradient(
style=HueLightGradientStyle.SCATTERED,
colors=[
HueLightColorXY(x=0.424, y=0.285),
HueLightColorXY(x=0.229, y=0.279),
],
)
| Attribute | Type | Description |
|---|---|---|
style |
HueLightGradientStyle |
The type of gradient effect. See below for options. |
colors |
list[HueLightColorXY] |
List of colors in the gradient. |
HueLightGradientStyle
This enum describes the different styles that can be used for custom gradients on light strips.
| Name | Decimal value | Hex value |
|---|---|---|
HueLightGradientStyle.LINEAR |
0 | 0x00 |
HueLightGradientStyle.SCATTERED |
2 | 0x02 |
HueLightGradientStyle.MIRRORED |
4 | 0x04 |
HueLightGradientParams
Gradient scale and offset parameters (for light strips). Values can be between 0 and 31.875 in increments of 0.125 (1/8).
| Attribute | Type | Description |
|---|---|---|
scale |
float |
Number of colors that should fit on the light strip. Ignored in the "scattered" gradient style. A value of 0 is special, blending all the gradient colors smoothly across the whole light strip. Read more at: https://github.com/chrivers/bifrost/blob/master/doc/hue-zigbee-format.md#property-gradient_params-scale |
offset |
float |
Number of lights to skip at the start of the light strip. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hue_zigbee_encoding-1.0.0.tar.gz.
File metadata
- Download URL: hue_zigbee_encoding-1.0.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3d27d0aa14a4597175dccdb25dc6e1054e99cad4829e29998d0c7715314493
|
|
| MD5 |
5e3720837d2d4b3c1fae35b1f86db8f4
|
|
| BLAKE2b-256 |
d0d9c0dc090b894060baf2d2128c19f693bf425d4ddebcab58aa00a9928b4565
|
Provenance
The following attestation bundles were made for hue_zigbee_encoding-1.0.0.tar.gz:
Publisher:
ci.yml on jtbandes/hue-zigbee-encoding
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hue_zigbee_encoding-1.0.0.tar.gz -
Subject digest:
ac3d27d0aa14a4597175dccdb25dc6e1054e99cad4829e29998d0c7715314493 - Sigstore transparency entry: 685544179
- Sigstore integration time:
-
Permalink:
jtbandes/hue-zigbee-encoding@7b344c7b3bbf492e058e9cf124362d47a08fda16 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jtbandes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@7b344c7b3bbf492e058e9cf124362d47a08fda16 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hue_zigbee_encoding-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hue_zigbee_encoding-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32815dbe51f92d4037ef814845452efd0ec239b2bed8b6524dc6cba317fc8c9f
|
|
| MD5 |
04a8e77efb2d0465ac38df35fc562ac0
|
|
| BLAKE2b-256 |
5f64041e22a3c594e34d4f9a38bfc1f856b226515f7bc93da6f9a3cb877c464a
|
Provenance
The following attestation bundles were made for hue_zigbee_encoding-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on jtbandes/hue-zigbee-encoding
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hue_zigbee_encoding-1.0.0-py3-none-any.whl -
Subject digest:
32815dbe51f92d4037ef814845452efd0ec239b2bed8b6524dc6cba317fc8c9f - Sigstore transparency entry: 685544183
- Sigstore integration time:
-
Permalink:
jtbandes/hue-zigbee-encoding@7b344c7b3bbf492e058e9cf124362d47a08fda16 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jtbandes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@7b344c7b3bbf492e058e9cf124362d47a08fda16 -
Trigger Event:
push
-
Statement type: