monster1025 / yeelight-mqtt

Yeelight Gateway to MQTT bridge (I use it for home assistant integration)
GNU General Public License v2.0
14 stars 15 forks source link

"home/light/main-color/rgb" 1247743 #2

Open m4dm4rtig4n opened 4 years ago

m4dm4rtig4n commented 4 years ago

Hi, what is this RGB code ? oO How to convert this to an readable RGB code ?

monster1025 commented 4 years ago

If I remember right - it is default home assistant rgb value.
It is converted rgb to int:

            # if (key == "rgb" and self._is_int(value)):
            #   intval = int(value)
            #   blue =  (intval) & 255
            #   green = (intval >> 8) & 255
            #   red =  (intval >> 16) & 255
            #   value = str(red)+","+str(green)+","+str(blue)

Also, you can send value as "r,g,b" or "255,200,100" - this format is ok too.

m4dm4rtig4n commented 4 years ago

On Home Assistant i have this error :

May 03 23:17:53 HomeAssistant hass[32734]: 2020-05-03 23:17:53 ERROR (MainThread) [homeassistant.util.logging] Exception in rgb_received when handling msg on 'yeelight/light/salon-lustre/rgb': '16741596'
May 03 23:17:53 HomeAssistant hass[32734]: Traceback (most recent call last):
May 03 23:17:53 HomeAssistant hass[32734]:   File "/usr/local/lib/python3.7/dist-packages/homeassistant/components/mqtt/debug_info.py", line 35, in wrapper
May 03 23:17:53 HomeAssistant hass[32734]:     msg_callback(msg)
May 03 23:17:53 HomeAssistant hass[32734]:   File "/usr/local/lib/python3.7/dist-packages/homeassistant/components/mqtt/light/schema_basic.py", line 361, in rgb_received
May 03 23:17:53 HomeAssistant hass[32734]:     self._hs = color_util.color_RGB_to_hs(*rgb)
May 03 23:17:53 HomeAssistant hass[32734]: TypeError: color_RGB_to_hs() missing 2 required positional arguments: 'iG' and 'iB'