diff --git a/custom_components/sengledapi/light.py b/custom_components/sengledapi/light.py index 43006f4..141c728 100755 --- a/custom_components/sengledapi/light.py +++ b/custom_components/sengledapi/light.py @@ -72,15 +72,18 @@ def __init__(self, light): @property def name(self): """Return the display name of this light.""" + _LOGGER.debug("Light.py Name %s", self._name) return self._name @property def unique_id(self): + _LOGGER.debug("Light.py unique_id %s", self._device_mac) return self._device_mac @property def available(self): """Return the connection status of this light""" + _LOGGER.debug("Light.py _avaliable %s", self._avaliable) return self._avaliable @property @@ -95,6 +98,11 @@ def extra_state_attributes(self): "rssi": self._device_rssi, "mac": self._device_mac, "alarm status ": self._alarm_status, + "color": self._color, + "color Temp": self._color_temperature, + "color r": self._rgb_color_r, + "color g": self._rgb_color_g, + "color b": self._rgb_color_b, } else: return { @@ -104,11 +112,17 @@ def extra_state_attributes(self): "device model": self._device_model, "rssi": self._device_rssi, "mac": self._device_mac, + "color": self._color, + "color Temp": self._color_temperature, + "color r": self._rgb_color_r, + "color g": self._rgb_color_g, + "color b": self._rgb_color_b, } @property def color_temp(self): """Return the color_temp of the light.""" + _LOGGER.debug("Light.py color_temp %s", self._color_temperature) if self._color_temperature is None: return colorutil.color_temperature_kelvin_to_mired(2000) else: @@ -117,6 +131,7 @@ def color_temp(self): @property def hs_color(self): """Return the hs_color of the light.""" + _LOGGER.debug("Light.py hs_color %s", self._color) if self._wifi_device: a, b, c = self._color.split(":") return colorutil.color_RGB_to_hs(int(a), int(b), int(c)) @@ -128,11 +143,13 @@ def hs_color(self): @property def brightness(self): """Return the brightness of the light.""" + _LOGGER.debug("Light.py brightness %s", self._brightness) return self._brightness @property def is_on(self): """Return true if light is on.""" + _LOGGER.debug("Light.py is_on %s", self._state) return self._state @property diff --git a/custom_components/sengledapi/sengledapi/devices/bulbs/bulb.py b/custom_components/sengledapi/sengledapi/devices/bulbs/bulb.py index dadc822..a4d2304 100755 --- a/custom_components/sengledapi/sengledapi/devices/bulbs/bulb.py +++ b/custom_components/sengledapi/sengledapi/devices/bulbs/bulb.py @@ -108,15 +108,16 @@ async def async_set_brightness(self, brightness): """Set Bulb Brightness""" if self._wifi_device: _LOGGER.info( - "Wifi Bulb %s %s setting brightness.", + "Wifi Bulb %s %s setting brightness %s, This is from HA ", self._friendly_name, self._device_mac, + str(brightness), ) brightness_precentage = round((brightness / 255) * 100) _LOGGER.info( - "SengledApi: Wifi Color Bulb %s %s setting Brighness %s", + "SengledApi: Wifi Color Bulb %s %s setting Brighness %s, This is what we are setting Sengled API", self._friendly_name, self._device_mac, str(brightness_precentage), @@ -148,6 +149,12 @@ async def async_set_brightness(self, brightness): ) async def async_color_temperature(self, color_temperature): + _LOGGER.info( + "Wifi Bulb %s %s setting color Temperature %s, This is from HA ", + self._friendly_name, + self._device_mac, + str(color_temperature), + ) """Set Color Temperature""" color_temperature_precentage = round( self.translate(int(color_temperature), 200, 6500, 1, 100) @@ -155,7 +162,7 @@ async def async_color_temperature(self, color_temperature): if self._wifi_device: _LOGGER.info( - "SengledApi: Wifi Color Bulb %s %s Set Color Temperature %s", + "SengledApi: Wifi Color Bulb %s %s Set Color Temperature %s, This is what we are setting Sengled API", self._friendly_name, self._device_mac, color_temperature_precentage, @@ -256,13 +263,11 @@ def is_on(self): async def async_update(self): if self._wifi_device: _LOGGER.info( - "SengledApi: Wifi Bulb " - + self._friendly_name - + " " - + self._device_mac - + " updating." + "SengledApi: Wifi Bulb %s %s is updating", + self._friendly_name, + self._device_mac, ) - if self._just_changed_state: + if not self._just_changed_state: _LOGGER.info( "SengledApi: Bulb State Change: %s", self._just_changed_state ) @@ -277,7 +282,7 @@ async def async_update(self): "SengledApi: Wifi Bulb " + self._friendly_name + " updating." ) for item in data["deviceList"]: - _LOGGER.debug("SengledApi: Wifi Bulb update return " + str(item)) + _LOGGER.debug("SengledApi: Wifi Bulb update return: %s", str(item)) bulbs.append(BulbProperty(self, item, True)) for items in bulbs: if items.uuid == self._device_mac: @@ -291,12 +296,10 @@ async def async_update(self): (int(items.brightness) / 100) * 255 ) if self._support_color_temp: - self._color_temperature = round( - self.translate( - int(items.color_temperature), 0, 100, 2000, 6500 - ) - ) + _LOGGER.debug("SengledApi: Wifi Bulb Colo Temp: %s", items.color_temperature) + self._color_temperature = round(self.translate(int(items.color_temperature), 0, 100, 2000, 6500)) if self._support_color: + _LOGGER.debug("SengledApi: Wifi Bulb Color: %s", items.color) self._color = items.color else: _LOGGER.info( diff --git a/custom_components/sengledapi/sengledapi/devices/bulbs/bulbproperty.py b/custom_components/sengledapi/sengledapi/devices/bulbs/bulbproperty.py index 5d43e1e..f29d1f0 100755 --- a/custom_components/sengledapi/sengledapi/devices/bulbs/bulbproperty.py +++ b/custom_components/sengledapi/sengledapi/devices/bulbs/bulbproperty.py @@ -53,7 +53,7 @@ def color_temperature(self): for attr in self._attributes: if attr["name"] == "colorTemperature": return int(attr["value"]) - return 2000 + #return 2000 else: if self._attributes["colorTemperature"]: color_temperature = self._info["attributes"]["colorTemperature"]