Closed andyman1222 closed 6 years ago
That is an old issue and is still working because the lighs api did not change. However after entertainment mode was released i sow is not possible to use http protocol because or the fast frame rate. In order to have entertainment mode working you need to use an ESP8266 board that has an udp server build inside just to catch these frames without to be overloaded.
I currently have the LEDs connected onto the GPIO pins of the rpi and don't have the wifi controller. Is there a way to run this udp server on the rpi directly?
On Sat, Aug 4, 2018, 1:06 AM Motea Marius notifications@github.com wrote:
That is an old issue and is still working because the lighs api did not change. However after entertainment mode was released i sow is not possible to use http protocol because or the fast frame rate. In order to have entertainment mode working you need to use an ESP8266 board that has an udp server build inside just to catch these frames without to be overloaded.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mariusmotea/diyHue/issues/308#issuecomment-410432600, or mute the thread https://github.com/notifications/unsubscribe-auth/ANmr_JioGEu2x3cAzde0_gPMPG2SxI7zks5uNVYMgaJpZM4Vu4oi .
Is easy to create an udp server in python script and to receive the bytes, but now i'm texting from my phone and cannot provide too many informations
In my code this is the udp server that listen on port 2101:
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) serverSocket.bind(('127.0.0.1', 2101)) while True: data = serverSocket.recvfrom(4)
I put there to receive just 4 bytes because only this you care, first 3 are r g b values and last one the light id. You will need to replace the udp port because there is one conflict, hue entertainment listen on 2100 and native lights also on 2100. You cannot start another local service on this port so replace it with something else, but ensure you replace also in HueEmulator3.py to use the new port for native lights instead of port 2100.
Thanks for the example, but is this supposed to replace the HTTPd content in what I currently have for my LEDs or is this supposed to be handled separately for entertainment mode? Also, what kind of data is this server receiving? more GET requests?
No, http requests are used for hue api only, entertainment api is different and is based on udp prptocol because it need to process about 25 requests per second. You need to keep both services on same script.
I just added the UDP code into the script and set the port to 2101. When I enter entertainment mode my code outputs the data recieved, which looks like:
'HueStream\x01\x00-\x00\x00\x00\x00\x00\x00\x00\x00\x00U\x80\x1c\xab\x00\x00\x01\x00\x00U\x80\x1c\xab
plus some more \x00 s because I increased the buffer size. Decoding to numbers results in something like:
[72, 117, 101, 83, 116, 114, 101, 97, 109, 1, 0, 174, 0, 0, 0, 0, 0, 0, 0, 255, 255, 205, 205, 0, 0, 0, 0, 1, 255, 255, 205, 205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
. I figured out that the first 12 elements aren't necessary for emulation, but starting at index 19 is the R value for your lights, at index 21 is green, and at 23 is blue, and indicies 20, 22, and 24 are just repeats im pretty sure. THen, I have a 2 light setup, so the same is repeated at index 29, and probably repeats for any other lights. The value at index 11 (174 in this data) also changes, but I'm not sure what it is. Nevertheless, I finally got these values into half of my LEDs, and they work great! In fact, I was able to get them synced with my razer keyboard in Overwatch (althoug hthe razer program reported them as offline, they still worked)! Tomorrow I'll post my code modifications.
port udp 2101 is also used, you receive native hue entertainment data instead of processed one from hue emulator. use 2102 or something else, You need to process just 4 bytes, r,g,b + the light id. Because you have two stripts ensure you use different light id's so you can address both independent.
Andyman, did you got it working? I'm right now also at this point. I got my pwm ikea dioder working with pi-blaster - but I am unable to connect it to the entertainment area. would you spare your code?
I just followed the instructions on #28 and got the emulator working on 2 sets of RGB LED strips I have, and got it all working with the app. However, when I try to open them in entertainment mode, they disconnect. There's no errors regarding issues on server side, however when I try to use Razer Synapse with the Hue bridge both my strips show up as disconnected. Furthermore, in the entertainment setup, the LEDs were not synced beyond the first step. Any idea how to fix this?