diff --git a/custom_components/dmx/light.py b/custom_components/dmx/light.py index 0ab54a6..f9ca2e3 100644 --- a/custom_components/dmx/light.py +++ b/custom_components/dmx/light.py @@ -1,7 +1,7 @@ """ Home Assistant support for DMX lights over IP. -Date: 2019-03-03 +Date: 2020-04-13 Homepage: https://github.com/jnimmo/hass-dmx Author: James Nimmo """ @@ -202,10 +202,9 @@ def __init__(self, light, dmx_gateway, send_immediately, default_type): # Brightness needs to be set to the maximum default RGB level, then # scale up the RGB values to what HA uses if self._rgb: - self._brightness = max(self._rgb) - self._rgb = scale_rgb_to_brightness(self._rgb, self._brightness) + self._brightness = max(self._rgb) * (self._brightness/255) - if self._brightness >= 0 or self._white_value >= 0: + if self._brightness > 0 or self._white_value > 0: self._state = STATE_ON else: self._state = STATE_OFF @@ -393,6 +392,9 @@ def async_turn_on(self, **kwargs): # Update state from service call if ATTR_BRIGHTNESS in kwargs: self._brightness = kwargs[ATTR_BRIGHTNESS] + + if self._brightness == 0: + self._brightness = 255 if ATTR_HS_COLOR in kwargs: self._rgb = color_util.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR])