mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
Fix brightness support for Tuya dimmers that use the Light ("dj") category (#60385)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
@@ -330,6 +330,7 @@ class TuyaLightEntity(TuyaEntity, LightEntity):
|
|||||||
_brightness_type: IntegerTypeData | None = None
|
_brightness_type: IntegerTypeData | None = None
|
||||||
_color_data_dpcode: DPCode | None = None
|
_color_data_dpcode: DPCode | None = None
|
||||||
_color_data_type: ColorTypeData | None = None
|
_color_data_type: ColorTypeData | None = None
|
||||||
|
_color_mode_dpcode: DPCode | None = None
|
||||||
_color_temp_dpcode: DPCode | None = None
|
_color_temp_dpcode: DPCode | None = None
|
||||||
_color_temp_type: IntegerTypeData | None = None
|
_color_temp_type: IntegerTypeData | None = None
|
||||||
|
|
||||||
@@ -361,6 +362,13 @@ class TuyaLightEntity(TuyaEntity, LightEntity):
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Determine color mode DPCode
|
||||||
|
if (
|
||||||
|
description.color_mode is not None
|
||||||
|
and description.color_mode in device.function
|
||||||
|
):
|
||||||
|
self._color_mode_dpcode = description.color_mode
|
||||||
|
|
||||||
# Determine DPCodes for color temperature
|
# Determine DPCodes for color temperature
|
||||||
if (
|
if (
|
||||||
isinstance(description.color_temp, DPCode)
|
isinstance(description.color_temp, DPCode)
|
||||||
@@ -451,10 +459,10 @@ class TuyaLightEntity(TuyaEntity, LightEntity):
|
|||||||
commands = [{"code": self.entity_description.key, "value": True}]
|
commands = [{"code": self.entity_description.key, "value": True}]
|
||||||
|
|
||||||
if self._color_temp_type and ATTR_COLOR_TEMP in kwargs:
|
if self._color_temp_type and ATTR_COLOR_TEMP in kwargs:
|
||||||
if color_mode_dpcode := self.entity_description.color_mode:
|
if self._color_mode_dpcode:
|
||||||
commands += [
|
commands += [
|
||||||
{
|
{
|
||||||
"code": color_mode_dpcode,
|
"code": self._color_mode_dpcode,
|
||||||
"value": WorkMode.WHITE,
|
"value": WorkMode.WHITE,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -476,10 +484,10 @@ class TuyaLightEntity(TuyaEntity, LightEntity):
|
|||||||
ATTR_HS_COLOR in kwargs
|
ATTR_HS_COLOR in kwargs
|
||||||
or (ATTR_BRIGHTNESS in kwargs and self.color_mode == COLOR_MODE_HS)
|
or (ATTR_BRIGHTNESS in kwargs and self.color_mode == COLOR_MODE_HS)
|
||||||
):
|
):
|
||||||
if color_mode_dpcode := self.entity_description.color_mode:
|
if self._color_mode_dpcode:
|
||||||
commands += [
|
commands += [
|
||||||
{
|
{
|
||||||
"code": color_mode_dpcode,
|
"code": self._color_mode_dpcode,
|
||||||
"value": WorkMode.COLOUR,
|
"value": WorkMode.COLOUR,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -651,9 +659,8 @@ class TuyaLightEntity(TuyaEntity, LightEntity):
|
|||||||
# We consider it to be in HS color mode, when work mode is anything
|
# We consider it to be in HS color mode, when work mode is anything
|
||||||
# else than "white".
|
# else than "white".
|
||||||
if (
|
if (
|
||||||
self.entity_description.color_mode
|
self._color_mode_dpcode
|
||||||
and self.device.status.get(self.entity_description.color_mode)
|
and self.device.status.get(self._color_mode_dpcode) != WorkMode.WHITE
|
||||||
!= WorkMode.WHITE
|
|
||||||
):
|
):
|
||||||
return COLOR_MODE_HS
|
return COLOR_MODE_HS
|
||||||
if self._color_temp_dpcode:
|
if self._color_temp_dpcode:
|
||||||
|
Reference in New Issue
Block a user