diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md
index aa521fa..d7dfd85 100644
--- a/DOCUMENTATION.md
+++ b/DOCUMENTATION.md
@@ -3,6 +3,7 @@
* [yahuelib](#yahuelib)
* [yahuelib.utils](#yahuelib.utils)
* [rgb\_to\_hsv](#yahuelib.utils.rgb_to_hsv)
+ * [kelvin\_to\_mired](#yahuelib.utils.kelvin_to_mired)
* [yahuelib.controller](#yahuelib.controller)
* [LightController](#yahuelib.controller.LightController)
* [reachable](#yahuelib.controller.LightController.reachable)
@@ -14,6 +15,8 @@
* [hue](#yahuelib.controller.LightController.hue)
* [saturation](#yahuelib.controller.LightController.saturation)
* [saturation](#yahuelib.controller.LightController.saturation)
+ * [color\_temperature](#yahuelib.controller.LightController.color_temperature)
+ * [color\_temperature](#yahuelib.controller.LightController.color_temperature)
* [alert](#yahuelib.controller.LightController.alert)
* [alert\_long](#yahuelib.controller.LightController.alert_long)
* [GroupController](#yahuelib.controller.GroupController)
@@ -26,6 +29,8 @@
* [hue](#yahuelib.controller.GroupController.hue)
* [saturation](#yahuelib.controller.GroupController.saturation)
* [saturation](#yahuelib.controller.GroupController.saturation)
+ * [color\_temperature](#yahuelib.controller.GroupController.color_temperature)
+ * [color\_temperature](#yahuelib.controller.GroupController.color_temperature)
* [alert](#yahuelib.controller.GroupController.alert)
* [alert\_long](#yahuelib.controller.GroupController.alert_long)
* [yahuelib.exceptions](#yahuelib.exceptions)
@@ -50,6 +55,16 @@ def rgb_to_hsv(r: int, g: int, b: int) -> tuple
Convert RGB colors `(255, 220, 100)` to HSV `(0.129, 0.608, 1.0)`
+
+
+#### kelvin\_to\_mired
+
+```python
+def kelvin_to_mired(kelvin: int)
+```
+
+Convert the color temperature from Kelvin to Mired
+
# yahuelib.controller
@@ -171,6 +186,28 @@ def saturation(saturation: float)
Set the saturation using `LightController.saturation = ...`
+
+
+#### color\_temperature
+
+```python
+@property
+def color_temperature()
+```
+
+Get the white color temperature in Mired using `LightController.color_temperature`
+
+
+
+#### color\_temperature
+
+```python
+@color_temperature.setter
+def color_temperature(mired: int)
+```
+
+Set the white color temperature in Mired (`154` - `500`) using `LightController.color_temperature = ...`
+
#### alert
@@ -308,6 +345,28 @@ def saturation(saturation: float)
Set the saturation of all lights in this group using `GroupController.saturation = ...`
+
+
+#### color\_temperature
+
+```python
+@property
+def color_temperature()
+```
+
+Get the last set white color temperature in Mired using `GroupController.color_temperature`
+
+
+
+#### color\_temperature
+
+```python
+@color_temperature.setter
+def color_temperature(mired: int)
+```
+
+Set the white color temperature in Mired (`154` - `500`) for all lights in this group using `GroupController.color_temperature = ...`
+
#### alert
diff --git a/README.md b/README.md
index b1fb8fa..7ba807e 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@ See https://developers.meethue.com/develop/get-started-2/
- brightness
- hue
- saturation
+ - white color temperature
- alert
- alert_long
- 🏠 Groups (Zones and Rooms)
@@ -23,6 +24,7 @@ See https://developers.meethue.com/develop/get-started-2/
- brightness
- hue
- saturation
+ - white color temperature
- alert
- alert_long
diff --git a/yahuelib/controller.py b/yahuelib/controller.py
index e3cd0fb..49349c3 100644
--- a/yahuelib/controller.py
+++ b/yahuelib/controller.py
@@ -133,6 +133,19 @@ class LightController(_BaseController):
sat_ = min(max(int(saturation * 254), 0), 254)
self._api_request("PUT", "/state", {"sat": sat_})
+ @property
+ def color_temperature(self):
+ '''Get the white color temperature in Mired using `LightController.color_temperature`'''
+ data = self._api_request()
+ return data["state"]["ct"]
+
+ @color_temperature.setter
+ def color_temperature(self, mired:int):
+ '''Set the white color temperature in Mired (`154` - `500`) using `LightController.color_temperature = ...`'''
+ assert type(mired) == int
+ ct_ = min(max(mired, 154), 500)
+ self._api_request("PUT", "/state", {"ct": ct_})
+
def alert(self):
'''Flash the light once.'''
self._api_request("PUT", "/state", {"alert": "select"})
@@ -213,6 +226,19 @@ class GroupController(_BaseController):
sat_ = min(max(int(saturation * 254), 0), 254)
self._api_request("PUT", "/action", {"sat": sat_})
+ @property
+ def color_temperature(self):
+ '''Get the last set white color temperature in Mired using `GroupController.color_temperature`'''
+ data = self._api_request()
+ return data["action"]["ct"]
+
+ @color_temperature.setter
+ def color_temperature(self, mired:int):
+ '''Set the white color temperature in Mired (`154` - `500`) for all lights in this group using `GroupController.color_temperature = ...`'''
+ assert type(mired) == int
+ ct_ = min(max(mired, 154), 500)
+ self._api_request("PUT", "/action", {"ct": ct_})
+
def alert(self):
'''Flash all lights in the group once.'''
self._api_request("PUT", "/action", {"alert": "select"})
diff --git a/yahuelib/utils.py b/yahuelib/utils.py
index 8d300db..e290714 100644
--- a/yahuelib/utils.py
+++ b/yahuelib/utils.py
@@ -13,3 +13,8 @@ def rgb_to_hsv(r:int, g:int, b:int) -> tuple:
g_ = g / 255.0
b_ = b / 255.0
return _rgb_to_hsv(r_, g_, b_)
+
+def kelvin_to_mired(kelvin:int):
+ '''Convert the color temperature from Kelvin to Mired'''
+ assert type(kelvin) == int
+ return round(1000000.0/kelvin)