Skip to content

Commit

Permalink
Improve entertainment for yeelight mariusmotea#305
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmotea authored Aug 1, 2018
1 parent 6557c46 commit 88f318e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions BridgeEmulator/HueEmulator3.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ def entertainmentService():
if bridge_config["lights_address"][str(lightId)]["protocol"] == "native":
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.sendto(bytes([r]) + bytes([g]) + bytes([b]) + bytes([bridge_config["lights_address"][str(lightId)]["light_nr"] - 1]), (bridge_config["lights_address"][str(lightId)]["ip"], 2100))
elif bridge_config["lights_address"][str(lightId)]["protocol"] == "yeelight":
if fremeID == 24 or fremeID == 48:
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.settimeout(1)
tcp_socket.connect((bridge_config["lights_address"][str(lightId)]["ip"], 55443))
msg = json.dumps({"id": 1, "method": "set_rgb", "params": [r * 65536 + g * 256 + r, "smooth", 100]}) + "\r\n"
tcp_socket.send(msg.encode())
tcp_socket.close()
else:
fremeID += 1
if fremeID == 24: #24 = every seconds, increase in case the destination device is overloaded
if r == 0 and g == 0 and b == 0:
sendLightRequest(str(lightId), {"bri": 1, "transitiontime": 1})
Expand All @@ -58,7 +65,9 @@ def entertainmentService():
elif fremeID == 48:
average_bri = int((r + b + g) / 3)
esendLightRequest(str(lightId), {"bri": average_bri, "transitiontime": 1})
fremeID = 0
fremeID += 1
if fremeID == 48:
fremeID = 0
updateGroupStats(lightId)
i = i + 9
elif data[14] == 1: #cie colorspace
Expand Down

0 comments on commit 88f318e

Please sign in to comment.