Skip to content

Commit

Permalink
Fix to color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
c503ghosh committed Mar 23, 2024
1 parent 906ad91 commit d689fad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
14 changes: 12 additions & 2 deletions custom_components/dirigera_platform/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def set_state(self):
can_receive = self._json_data.capabilities.can_receive
logger.debug("Got can_receive in state")
logger.debug(can_receive)
self._color_mode = ColorMode.UNKNOWN
for cap in can_receive:
if cap == "lightLevel":
color_modes.append(ColorMode.BRIGHTNESS)
Expand All @@ -74,11 +75,20 @@ def set_state(self):
color_modes.append(ColorMode.HS)

if len(color_modes) == 0:
self._supported_color_modes = ColorMode.UNKNOWN
logger.debug("Color modes array is zero, setting to UNKNOWN")
self._supported_color_modes = [ColorMode.UNKNOWN]
else:
self._supported_color_modes = color_modes
if ColorMode.HS in self._supported_color_modes:
self._color_mode = ColorMode.HS
elif ColorMode.COLOR_TEMP in self._supported_color_modes:
self._color_mode = ColorMode.COLOR_TEMP
elif ColorMode.BRIGHTNESS in self._supported_color_modes:
self._color_mode = ColorMode.BRIGHTNESS

logger.debug("supported color mode set to ")
logger.debug(self._supported_color_modes)
logger.debug(self._color_mode)

@property
def unique_id(self):
Expand Down Expand Up @@ -136,7 +146,7 @@ def supported_color_modes(self):

@property
def color_mode(self):
return self._supported_color_modes
return self._color_mode

def update(self):
try:
Expand Down
18 changes: 18 additions & 0 deletions custom_components/dirigera_platform/mocks/ikea_bulb_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def __init__(self) -> None:
ColorMode.COLOR_TEMP,
ColorMode.HS,
]

if len(self._supported_color_modes) == 0:
logger.debug("Color modes array is zero, setting to UNKNOWN")
self._supported_color_modes = [ColorMode.UNKNOWN]
else:
if ColorMode.HS in self._supported_color_modes:
self._color_mode = ColorMode.HS
elif ColorMode.COLOR_TEMP in self._supported_color_modes:
self._color_mode = ColorMode.COLOR_TEMP
elif ColorMode.BRIGHTNESS in self._supported_color_modesor_modes:
self._color_mode = ColorMode.BRIGHTNESS

self._color_temp = 3000
self._min_color_temp = 2202
self._max_color_temp = 4000
Expand Down Expand Up @@ -86,8 +98,14 @@ def is_on(self):

@property
def supported_color_modes(self):
logger.debug("returning supported colors")
return self._supported_color_modes

@property
def color_mode(self):
logger.debug("Returning color mode")
return self._color_mode

def update(self):
logger.debug("mock update for {}...".format(self._name))
pass
Expand Down

0 comments on commit d689fad

Please sign in to comment.