diyhue / Lights

DIY lights with support for diyHue
https://diyhue.org/
172 stars 97 forks source link

Custom diyHue Light Implementation #108

Closed philib closed 3 years ago

philib commented 3 years ago

Hi,

i would like to synchronize my Philips TV with Ambilight+Hue feature with a RGB LED bar. For this I would like to use my Raspberry Pi. Accordingly, to realize the project, the Pi must act as both a hub and a light.

Unfortunately I have not found any specification of a diyHue light. Is there a SDK besides the existing firmware? If not, shouldn't it be enough to provide a web server on the local network with the '/detect' route (and the corresponding response) to be detected as a light by the hub (i'm using the Docker image)? I have mocked the '/detect' route for now, but I could not find my "light" with the Hue Essentials app. Did I forget something?

Thanks in advance

mariusmotea commented 3 years ago

The main issue is that port 80 is used by bridge emulator and cannot be used also by the light. You can manually add the light to config.json file of the bridge emulator. This way you can specify manually other free port.

philib commented 3 years ago

Ok, this might be a problem i need to solve later on. Currently im running the light webserver mock on a different machine. Therefore there should not be a port related issue. The emulator is able to find my machine in the network. I tested this with an nmap scan inside the container.

@mariusmotea i'll try adding the light manually anyway. I already considered doing this, but i could figure out the correct json format. Is there a json schema/specification for adding lights manually?

ryancasler commented 3 years ago

Are you running DIYHue in docker in Bridge or Host network mode? If Host, then you are going to run into problems. If in Bridge, then use the bridge IP address to talk from your container to your host OS. So, the IP address should be something like 172.17.0.1 within your host OS and then each container will get an IP in that subnet. So, 172.17.0.2, etc. That would be the best way if you are running in Bridge (default) networking mode. However, you are going to run into problems accessing DIYHue from any other apps if something on the host OS is running on port 80. You can't have two apps running on the same IP on the same port. It just won't work.

I would suggest you run DIYHue in MACVLAN mode within docker. That will give you a separate IP address on your main network for the container. You would then access this new IP to access DIYHue. This is the what I had to do since I have multiple apps all trying to use port 80 on my server.

philib commented 3 years ago

@ryancasler does the network mode matter even if i'm currently mocking the light on a different physical machine in the local network? I tried the bridge mode, but also couldn't find my light mock either.

Im currently running a simple webserver serving json mocks on following routes

Should'nt that be enough for the diyHue Emulator to find my "light"?

Edit:

The emulator detects my mocked light now. Don't know what went wrong earlier. I'm running diyHue in host mode. A reason could be that i returned xy with 3 elements instead of 2, but that's just a guess.

philib commented 3 years ago

The main issue is that port 80 is used by bridge emulator and cannot be used also by the light. You can manually add the light to config.json file of the bridge emulator. This way you can specify manually other free port.

@mariusmotea I tried to change the port in the config.json manually but the emulator is not able to communicate with my light anymore. Am i missing something?

EDIT: i was first editing the config.json directly in the container. Editing the mounted config.json and restarting the container finally worked.

philib commented 3 years ago

Hi again, i hooked up a led lightstrip to my raspberry pi and am now able to control it via the Hue Essentials app. The next step was to try the entertainment mode. So i created a mocked light again listening to udp packets on the corresponding port 2100. I successfully tested the "Sync" mode of the Essentials app using the camera sync feature (running the light server on my desktop pc). You can find the code in my repository.

However if i'm running the server on my raspberry pi and test the entertainment mode using camera sync, the camera preview of the entertainment app does not work properly. Also, the server does recieve some udp packages now and then but rgb data remains always the same { r: 254, g: 255, b: 0 }.

Do you have any idea what's causing this issue?

Thanks in advance

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 2 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed as it has not had any recent activity. Thank you for your contributions.