Skip to content

Commit

Permalink
services/entertainment: use XY directly if provided by frame (#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
hre999 authored Nov 22, 2023
1 parent c944104 commit 83f3d73
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions BridgeEmulator/services/entertainment.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def entertainmentService(group, user):

else:
data = p.stdout.read(frameBites)
logging.debug(",".join('{:02x}'.format(x) for x in data))
#logging.debug(",".join('{:02x}'.format(x) for x in data))
nativeLights = {}
esphomeLights = {}
mqttLights = []
Expand All @@ -132,6 +132,7 @@ def entertainmentService(group, user):
while (i < counter):
light = None
r,g,b = 0,0,0
bri = 0
if apiVersion == 1:
if (data[i+1] * 256 + data[i+2]) in channels:
channels[data[i+1] * 256 + data[i+2]] += 1
Expand Down Expand Up @@ -166,12 +167,19 @@ def entertainmentService(group, user):
if light == None:
logging.info("error in light identification")
break
logging.debug("Light:" + str(light.name) + " RED: " + str(r) + ", GREEN: " + str(g) + ", BLUE: " + str(b) )
logging.debug("Frame: " + str(frameID) + " Light:" + str(light.name) + " RED: " + str(r) + ", GREEN: " + str(g) + ", BLUE: " + str(b) )
proto = light.protocol
if r == 0 and g == 0 and b == 0:
light.state["on"] = False
else:
light.state.update({"on": True, "bri": int((r + g + b) / 3), "xy": convert_rgb_xy(r, g, b), "colormode": "xy"})
if bri == 0:
light.state.update({"on": True, "bri": int((r + g + b) / 3), "xy": convert_rgb_xy(r, g, b), "colormode": "xy"})
else:
light.state.update({"on": True, "bri": bri, "xy": [x, y], "colormode": "xy"})
#logging.debug("in X: " + str(x) + " Y: " + str(y) + " B: " + str(bri))
#logging.debug("st X: " + str(light.state["xy"][0]) + " Y: " + str(light.state["xy"][1]) + " B: " + str(light.state["bri"]))
#logging.debug("co XY: " + str(convert_rgb_xy(r, g, b)) + " B: " + str((r + g + b) / 3))

if proto in ["native", "native_multi", "native_single"]:
if light.protocol_cfg["ip"] not in nativeLights:
nativeLights[light.protocol_cfg["ip"]] = {}
Expand Down

0 comments on commit 83f3d73

Please sign in to comment.