|
@@ -186,9 +186,21 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
return self._white_brightness
|
|
return self._white_brightness
|
|
|
|
|
|
|
|
@property
|
|
@property
|
|
|
- def _white_brightness(self):
|
|
|
|
|
|
|
+ def _effective_brightness_range(self):
|
|
|
|
|
+ """Get the effective brightness range of the light"""
|
|
|
if self._brightness_dps:
|
|
if self._brightness_dps:
|
|
|
r = self._brightness_dps.range(self._device)
|
|
r = self._brightness_dps.range(self._device)
|
|
|
|
|
+ if r:
|
|
|
|
|
+ if self._switch_dps is None and r[0] == 0:
|
|
|
|
|
+ # If the light has no switch, and the brightness range starts
|
|
|
|
|
+ # at 0, the effective minimum brightness is 1
|
|
|
|
|
+ r[0] = self._brightness_dps.step(self._device, False)
|
|
|
|
|
+ return r
|
|
|
|
|
+
|
|
|
|
|
+ @property
|
|
|
|
|
+ def _white_brightness(self):
|
|
|
|
|
+ if self._brightness_dps:
|
|
|
|
|
+ r = self._effective_brightness_rang
|
|
|
val = self._brightness_dps.get_value(self._device)
|
|
val = self._brightness_dps.get_value(self._device)
|
|
|
if r and val:
|
|
if r and val:
|
|
|
val = color_util.value_to_brightness(r, val)
|
|
val = color_util.value_to_brightness(r, val)
|
|
@@ -302,7 +314,7 @@ 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)
|
|
|
- r = self._brightness_dps.range(self._device)
|
|
|
|
|
|
|
+ r = self._effective_brightness_range
|
|
|
if r:
|
|
if r:
|
|
|
bright = _ha_brightness_to_dp_value(bright, r)
|
|
bright = _ha_brightness_to_dp_value(bright, r)
|
|
|
|
|
|
|
@@ -475,7 +487,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
):
|
|
):
|
|
|
bright = params.get(ATTR_BRIGHTNESS)
|
|
bright = params.get(ATTR_BRIGHTNESS)
|
|
|
|
|
|
|
|
- r = self._brightness_dps.range(self._device)
|
|
|
|
|
|
|
+ r = self._effective_brightness_range
|
|
|
if r:
|
|
if r:
|
|
|
bright = _ha_brightness_to_dp_value(bright, r)
|
|
bright = _ha_brightness_to_dp_value(bright, r)
|
|
|
_LOGGER.info("%s setting brightness to %d", self._config.config_id, bright)
|
|
_LOGGER.info("%s setting brightness to %d", self._config.config_id, bright)
|
|
@@ -528,7 +540,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
|
|
|
)
|
|
)
|
|
|
):
|
|
):
|
|
|
bright = 255
|
|
bright = 255
|
|
|
- r = self._brightness_dps.range(self._device)
|
|
|
|
|
|
|
+ r = self._effective_brightness_range
|
|
|
if r:
|
|
if r:
|
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
bright = color_util.brightness_to_value(r, bright)
|
|
|
_LOGGER.info(
|
|
_LOGGER.info(
|