|
@@ -283,10 +283,6 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
color_mode = ColorMode.WHITE
|
|
color_mode = ColorMode.WHITE
|
|
|
if ATTR_BRIGHTNESS not in params and self._brightness_dps:
|
|
if ATTR_BRIGHTNESS not in params and self._brightness_dps:
|
|
|
bright = params.get(ATTR_WHITE)
|
|
bright = params.get(ATTR_WHITE)
|
|
|
- _LOGGER.debug(
|
|
|
|
|
- "Setting brightness via WHITE parameter to %d",
|
|
|
|
|
- bright,
|
|
|
|
|
- )
|
|
|
|
|
r = self._brightness_dps.range(self._device)
|
|
r = self._brightness_dps.range(self._device)
|
|
|
if r:
|
|
if r:
|
|
|
# ensure full range is used
|
|
# ensure full range is used
|
|
@@ -295,6 +291,9 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
else:
|
|
else:
|
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
|
|
|
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s setting white brightness to %d", self._config.config_id, bright
|
|
|
|
|
+ )
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._brightness_dps.get_values_to_set(
|
|
**self._brightness_dps.get_values_to_set(
|
|
@@ -315,7 +314,9 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
if color_temp > self.max_color_temp_kelvin:
|
|
if color_temp > self.max_color_temp_kelvin:
|
|
|
color_temp = self.max_color_temp_kelvin
|
|
color_temp = self.max_color_temp_kelvin
|
|
|
|
|
|
|
|
- _LOGGER.debug("Setting color temp to %d", color_temp)
|
|
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s setting color temp to %d", self._config.config_id, color_temp
|
|
|
|
|
+ )
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._color_temp_dps.get_values_to_set(
|
|
**self._color_temp_dps.get_values_to_set(
|
|
@@ -383,11 +384,13 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
ordered.append(val)
|
|
ordered.append(val)
|
|
|
idx += 1
|
|
idx += 1
|
|
|
binary = pack(fmt["format"], *ordered)
|
|
binary = pack(fmt["format"], *ordered)
|
|
|
|
|
+ encoded = self._rgbhsv_dps.encode_value(binary)
|
|
|
|
|
+ _LOGGER.info("%s setting color to %s", self._config.config_id, encoded)
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._rgbhsv_dps.get_values_to_set(
|
|
**self._rgbhsv_dps.get_values_to_set(
|
|
|
self._device,
|
|
self._device,
|
|
|
- self._rgbhsv_dps.encode_value(binary),
|
|
|
|
|
|
|
+ encoded,
|
|
|
settings,
|
|
settings,
|
|
|
),
|
|
),
|
|
|
}
|
|
}
|
|
@@ -399,6 +402,9 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
best_match = self.named_color_from_hsv(hs, brightness)
|
|
best_match = self.named_color_from_hsv(hs, brightness)
|
|
|
_LOGGER.debug("Setting color to %s", best_match)
|
|
_LOGGER.debug("Setting color to %s", best_match)
|
|
|
if best_match:
|
|
if best_match:
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s setting named color to %s", self._config.config_id, best_match
|
|
|
|
|
+ )
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._named_color_dps.get_values_to_set(
|
|
**self._named_color_dps.get_values_to_set(
|
|
@@ -409,7 +415,11 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
}
|
|
}
|
|
|
if self._color_mode_dps:
|
|
if self._color_mode_dps:
|
|
|
if color_mode:
|
|
if color_mode:
|
|
|
- _LOGGER.debug("Auto setting color mode to %s", color_mode)
|
|
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s auto setting color mode to %s",
|
|
|
|
|
+ self._config.config_id,
|
|
|
|
|
+ color_mode,
|
|
|
|
|
+ )
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._color_mode_dps.get_values_to_set(
|
|
**self._color_mode_dps.get_values_to_set(
|
|
@@ -429,8 +439,9 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
self._color_mode_dps.default
|
|
self._color_mode_dps.default
|
|
|
or self._color_mode_dps.values(self._device)[0]
|
|
or self._color_mode_dps.values(self._device)[0]
|
|
|
)
|
|
)
|
|
|
- _LOGGER.debug(
|
|
|
|
|
- "Emulating effect using color mode of %s",
|
|
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s emulating effect using color mode of %s",
|
|
|
|
|
+ self._config.config_id,
|
|
|
effect,
|
|
effect,
|
|
|
)
|
|
)
|
|
|
settings = {
|
|
settings = {
|
|
@@ -448,7 +459,6 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
and self._brightness_dps
|
|
and self._brightness_dps
|
|
|
):
|
|
):
|
|
|
bright = params.get(ATTR_BRIGHTNESS)
|
|
bright = params.get(ATTR_BRIGHTNESS)
|
|
|
- _LOGGER.debug("Setting brightness to %s", bright)
|
|
|
|
|
|
|
|
|
|
r = self._brightness_dps.range(self._device)
|
|
r = self._brightness_dps.range(self._device)
|
|
|
if r:
|
|
if r:
|
|
@@ -458,6 +468,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
else:
|
|
else:
|
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
|
|
|
|
|
|
|
|
+ _LOGGER.info("%s setting brightness to %d", self._config.config_id, bright)
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._brightness_dps.get_values_to_set(
|
|
**self._brightness_dps.get_values_to_set(
|
|
@@ -470,7 +481,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
if self._effect_dps:
|
|
if self._effect_dps:
|
|
|
effect = params.get(ATTR_EFFECT, None)
|
|
effect = params.get(ATTR_EFFECT, None)
|
|
|
if effect:
|
|
if effect:
|
|
|
- _LOGGER.debug("Setting effect to %s", effect)
|
|
|
|
|
|
|
+ _LOGGER.info("%s setting effect to %s", self._config.config_id, effect)
|
|
|
settings = {
|
|
settings = {
|
|
|
**settings,
|
|
**settings,
|
|
|
**self._effect_dps.get_values_to_set(
|
|
**self._effect_dps.get_values_to_set(
|
|
@@ -489,10 +500,14 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
# Special case for motion sensor lights with readonly switch
|
|
# Special case for motion sensor lights with readonly switch
|
|
|
# that have tristate switch available as effect
|
|
# that have tristate switch available as effect
|
|
|
if self._effect_dps.id not in settings:
|
|
if self._effect_dps.id not in settings:
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s turning light on using effect", self._config.config_id
|
|
|
|
|
+ )
|
|
|
settings = settings | self._effect_dps.get_values_to_set(
|
|
settings = settings | self._effect_dps.get_values_to_set(
|
|
|
self._device, "on", settings
|
|
self._device, "on", settings
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
|
|
+ _LOGGER.info("%s turning light on", self._config.config_id)
|
|
|
settings = settings | self._switch_dps.get_values_to_set(
|
|
settings = settings | self._switch_dps.get_values_to_set(
|
|
|
self._device, True, settings
|
|
self._device, True, settings
|
|
|
)
|
|
)
|
|
@@ -501,7 +516,11 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
r = self._brightness_dps.range(self._device)
|
|
r = self._brightness_dps.range(self._device)
|
|
|
if r:
|
|
if r:
|
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
|
-
|
|
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s turning light on to brightness %d",
|
|
|
|
|
+ self._config.config_id,
|
|
|
|
|
+ bright,
|
|
|
|
|
+ )
|
|
|
settings = settings | self._brightness_dps.get_values_to_set(
|
|
settings = settings | self._brightness_dps.get_values_to_set(
|
|
|
self._device, bright, settings
|
|
self._device, bright, settings
|
|
|
)
|
|
)
|
|
@@ -518,15 +537,21 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
):
|
|
):
|
|
|
# Special case for motion sensor lights with readonly switch
|
|
# Special case for motion sensor lights with readonly switch
|
|
|
# that have tristate switch available as effect
|
|
# that have tristate switch available as effect
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s turning light off using effect", self._config.config_id
|
|
|
|
|
+ )
|
|
|
await self._effect_dps.async_set_value(self._device, "off")
|
|
await self._effect_dps.async_set_value(self._device, "off")
|
|
|
else:
|
|
else:
|
|
|
|
|
+ _LOGGER.info("%s turning light off", self._config.config_id)
|
|
|
await self._switch_dps.async_set_value(self._device, False)
|
|
await self._switch_dps.async_set_value(self._device, False)
|
|
|
elif self._brightness_dps:
|
|
elif self._brightness_dps:
|
|
|
|
|
+ _LOGGER.info(
|
|
|
|
|
+ "%s turning light off by setting brightness to 0",
|
|
|
|
|
+ self._config.config_id,
|
|
|
|
|
+ )
|
|
|
await self._brightness_dps.async_set_value(self._device, 0)
|
|
await self._brightness_dps.async_set_value(self._device, 0)
|
|
|
else:
|
|
else:
|
|
|
raise NotImplementedError()
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
async def async_toggle(self):
|
|
async def async_toggle(self):
|
|
|
- disp_on = self.is_on
|
|
|
|
|
-
|
|
|
|
|
- await (self.async_turn_on() if not disp_on else self.async_turn_off())
|
|
|
|
|
|
|
+ await (self.async_turn_off() if self.is_on else self.async_turn_on())
|