Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
SKULSHADY committed Jan 9, 2025
1 parent 4ecf43d commit c87275c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
# light
CONF_BRIGHTNESS_LOWER = "brightness_lower"
CONF_BRIGHTNESS_UPPER = "brightness_upper"
CONF_COLOR = "color"
CONF_COLOUR_DATA = "colour_data"
CONF_COLOR_MODE = "color_mode"
CONF_COLOR_MODE_SET = "color_mode_set"
CONF_COLOR_TEMP_MIN_KELVIN = "color_temp_min_kelvin"
Expand Down
26 changes: 13 additions & 13 deletions custom_components/localtuya/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .const import (
CONF_BRIGHTNESS_LOWER,
CONF_BRIGHTNESS_UPPER,
CONF_COLOR,
CONF_COLOUR_DATA,
CONF_COLOR_MODE,
CONF_COLOR_MODE_SET,
CONF_COLOR_TEMP_MAX_KELVIN,
Expand Down Expand Up @@ -181,7 +181,7 @@ def flow_schema(dps):
),
vol.Optional(CONF_COLOR_MODE): col_to_select(dps, is_dps=True),
vol.Required(CONF_COLOR_MODE_SET, default="0"): col_to_select(MODES_SET),
vol.Optional(CONF_COLOR): col_to_select(dps, is_dps=True),
vol.Optional(CONF_COLOUR_DATA): col_to_select(dps, is_dps=True),
vol.Optional(CONF_COLOR_TEMP_MIN_KELVIN, default=DEFAULT_MIN_KELVIN): vol.All(
vol.Coerce(int), vol.Range(min=1500, max=8000)
),
Expand Down Expand Up @@ -265,8 +265,8 @@ def connection_made(self):

self._effect_list = list(self._scenes.keys()) + self._effect_list

if self.has_config(CONF_COLOR):
color_data = self.dp_value(CONF_COLOR)
if self.has_config(CONF_COLOUR_DATA):
color_data = self.dp_value(CONF_COLOUR_DATA)
if is_write_only and not color_data:
self.__to_color = self.__to_color_raw
self.__from_color = self.__from_color_raw
Expand All @@ -286,7 +286,7 @@ def extra_state_attributes(self):
"""
attributes = super().extra_state_attributes

extra_attrs = (CONF_COLOR_MODE, CONF_COLOR, CONF_BRIGHTNESS, CONF_COLOR_TEMP)
extra_attrs = (CONF_COLOR_MODE, CONF_COLOUR_DATA, CONF_BRIGHTNESS, CONF_COLOR_TEMP)
for attr in extra_attrs:
dp = self._config.get(attr)
if dp is not None and (state := self._status.get(dp)) is not None:
Expand Down Expand Up @@ -385,10 +385,10 @@ def supported_color_modes(self) -> set[ColorMode] | set[str] | None:
color_modes.add(ColorMode.COLOR_TEMP)
elif self.has_config(CONF_BRIGHTNESS):
color_modes.add(ColorMode.WHITE)
if self.has_config(CONF_COLOR):
if self.has_config(CONF_COLOUR_DATA):
color_modes.add(ColorMode.HS)

if self.has_config(CONF_COLOR):
if self.has_config(CONF_COLOUR_DATA):
color_modes.add(ColorMode.HS)

if color_modes == {ColorMode.WHITE}:
Expand Down Expand Up @@ -451,7 +451,7 @@ def color_mode(self) -> ColorMode:

def __is_color_rgb_encoded(self):
# for now we will prefer non encoded if color is none "added by manual or cloud pull dp"
color = self.dp_value(CONF_COLOR)
color = self.dp_value(CONF_COLOUR_DATA)
return False if color is None else len(color) > 12

def __find_scene_by_scene_data(self, data):
Expand Down Expand Up @@ -577,7 +577,7 @@ async def async_turn_on(self, **kwargs):
if ATTR_BRIGHTNESS in kwargs and (
ColorMode.BRIGHTNESS in color_modes
or self.has_config(CONF_BRIGHTNESS)
or self.has_config(CONF_COLOR)
or self.has_config(CONF_COLOUR_DATA)
):
brightness = map_range(
int(kwargs[ATTR_BRIGHTNESS]),
Expand All @@ -588,7 +588,7 @@ async def async_turn_on(self, **kwargs):
)

if self.is_color_mode and self._hs is not None:
states[self._config.get(CONF_COLOR)] = self.__to_color(
states[self._config.get(CONF_COLOUR_DATA)] = self.__to_color(
self._hs, brightness
)
color_mode = self._modes.color
Expand All @@ -604,7 +604,7 @@ async def async_turn_on(self, **kwargs):
states[self._config.get(CONF_BRIGHTNESS)] = brightness
color_mode = self._modes.white
else:
states[self._config.get(CONF_COLOR)] = self.__to_color(hs, brightness)
states[self._config.get(CONF_COLOUR_DATA)] = self.__to_color(hs, brightness)
color_mode = self._modes.color

if ATTR_COLOR_TEMP in kwargs and ColorMode.COLOR_TEMP in color_modes:
Expand Down Expand Up @@ -652,7 +652,7 @@ def status_updated(self):
self._brightness = brightness_dp_value

if ColorMode.HS in self.supported_color_modes:
color = self.dp_value(CONF_COLOR)
color = self.dp_value(CONF_COLOUR_DATA)
if color is not None and not self.is_white_mode:
self.__from_color(color)
elif self._brightness is None:
Expand All @@ -677,7 +677,7 @@ def status_updated(self):

def status_restored(self, stored_state) -> None:
"""Device status was restored."""
restore_attrs = (CONF_COLOR_MODE, CONF_COLOR, CONF_BRIGHTNESS, CONF_COLOR_TEMP)
restore_attrs = (CONF_COLOR_MODE, CONF_COLOUR_DATA, CONF_BRIGHTNESS, CONF_COLOR_TEMP)
if self._write_only:
for attr in restore_attrs:
dp = self._config.get(attr)
Expand Down

0 comments on commit c87275c

Please sign in to comment.