Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get current RGBA value and set it #1

Closed
wants to merge 15 commits into from
Next Next commit
Get current RGBA value and set it
When controlling gateway from Homekit, this implementation correctly updates state (on/off)
but does not update brightness and color (if it is set from homekit)

this patch adresses that and parses incoming value.
  • Loading branch information
quarcko committed Jul 11, 2019
commit e974d980165f6f5fc8f8dc68624a91849102e146
13 changes: 13 additions & 0 deletions light.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ def turn_off(self, **kwargs):
def parse_incoming_data(self, params, event, model, sid):
if params is None:
return False

rgba_raw = params.get("rgb")
if rgba_raw is not None:
rgbhexstr = "%x" % rgba_raw
if len(rgbhexstr) <= 8:
rgbhexstr = rgbhexstr.zfill(8)
rgbhex = bytes.fromhex(rgbhexstr)
rgba = struct.unpack('BBBB', rgbhex)
brightness = rgba[0]
rgb = rgba[1:]

self._brightness = brightness
self._hs = color_util.color_RGB_to_hs(*rgb)

light = params.get("light")
if light is not None:
Expand Down