Skip to content

Commit

Permalink
More accurately convert colortemp to xy and hs
Browse files Browse the repository at this point in the history
  • Loading branch information
dn0sar committed May 29, 2021
1 parent 8a3c34b commit 50631a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/circadian_lighting/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"issue_tracker": "https://github.com/claytonjn/hass-circadian_lighting/issues",
"dependencies": ["sensor","switch"],
"codeowners": ["@claytonjn"],
"requirements": [],
"requirements": ["colour-science"],
"iot_class": "calculated"
}
6 changes: 4 additions & 2 deletions custom_components/circadian_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from itertools import repeat

import voluptuous as vol
import colour

import homeassistant.helpers.config_validation as cv
from homeassistant.components.light import (
Expand Down Expand Up @@ -299,7 +300,7 @@ def _calc_rgb(self):
return color_temperature_to_rgb(self._color_temperature())

def _calc_xy(self):
return color_RGB_to_xy(*self._calc_rgb())
return list(colour.temperature.CCT_to_xy_CIE_D(self._color_temperature()))

def _calc_hs(self):
return color_xy_to_hs(*self._calc_xy())
Expand Down Expand Up @@ -352,7 +353,8 @@ async def _adjust_lights(self, lights, transition):
if not is_on(self.hass, light):
continue

service_data = {ATTR_ENTITY_ID: light, ATTR_TRANSITION: transition}
service_data = {ATTR_ENTITY_ID: light}
#service_data[ATTR_TRANSITION] = transition
if self._brightness is not None:
service_data[ATTR_BRIGHTNESS] = int((self._brightness / 100) * 254)

Expand Down

0 comments on commit 50631a4

Please sign in to comment.