0

At home I've got Philips hue and along that I've made some custom Pi and Arduino powered LED lighting which I would like to use in the same way by using the hue App.

I want to use the Pi as some kind of proxy to the bridge but have no idea how to accomplish it, nor knowledge about the commands needed and so I need some pointers into the right direction.

The Pi is able to control everything (the hue lamps on behalf of the hue bridge) and I don't really want to mess around with ZigBee. The idea is to put a Raspberry Pi with a second Ethernet port between the router and the hue bridge. The Pi has the state of all hue lamps by getting the responses from the hue bridge and the state of my custom LED lighting. Queries from the App pass the Pi then the response gets enriched and returned to the App. This way it appears as there are more lamps in the hue App.

For that the Pi needs to intercept HTTP requests to the hue bridge (and perform requests on itself), respond to them accordingly and not block any other traffic. That includes DHCP, SSDP (UPnP) and other stuff that are required to access the hue bridge over the internet.

  • Do you have any details on how the Hue protocol works? Does the Hue app support multiple Hue devices? Why do you need/want to make the Pi man-in-the-middle? Could you just make the Pi appear to the Hue app as another Hue device - that is, implement on the Pi whatever the Hue device implements to make the app treat it as a Hue device? – Mark Smith Nov 9 '16 at 19:54
  • I'am only aware of the REST-API which is documented.The point is that the hue bridge communicates with a service hosted by Philips that allows controlling the light with your smart phone over the internet. It does that using other protocols that are not that easy to me like plain unencrypted HTTP. And I don't like to lose the functionality. So I can't replace it that easily. I want to fake additional bulbs. The App itself can only communicate with one bridge at once. – kwasmich Nov 9 '16 at 20:17
  • Your question is not really about Raspberry Pis - it's a question about the Hue stuff. Unfortunately I don't think this is the right place for your question. – Mark Smith Nov 9 '16 at 20:53
  • ...unless all that detail is irrelevant and you're really just asking how to intercept HTTP traffic and route through everything else..? – Mark Smith Nov 9 '16 at 21:25
  • Due to lack of other ideas and skills... yes, that is basically the idea. I also have full access to the router which runs DD-WRT if it is of any help. So maybe a detour instead of a pass-through would also be an option. – kwasmich Nov 9 '16 at 22:25
2

It sounds like a good bet would be to set up a web proxy which allows you to modify the data on its way through, and then do whatever you were planning to do with the intercepted data.

Have a look at MITMProxy or Burp Suite. Burp Suite is pretty good but I can't remember whether it lets you pass the intercepted data to another program for modification. It looks like MITMProxy does allow you to do that.

Another reasonable solution would be to write your own web proxy - a basic one is really not too hard to write in, for example, Python. Have a look at this question as a starting point.

You don't give any indication of your level of programming expertise but given that you understand and seem happy with the concept of needing to modify the HTTP, I guess you're comfortable to some level.

  • This sounds completely feasible. Let's see if I can get it working. – kwasmich Nov 12 '16 at 17:48
  • I tried it using Node.js and the http-proxy package. It sort of worked. But not exactly the way I was thinking of. I configured the proxy on the hue bridge and all I saw was the outgoing home calls to Philips. So what I had to do is to set the HTTP-Proxy on my iPhone. That way I was able to see the requests of the hue App. (Didn't manage to see/edit the response yet). But setting the HTTP-Proxy on my iPhone interferes with almost every other App/service. Now it is clear to me that a HTTP-Proxy does not do the trick. – kwasmich Nov 12 '16 at 20:28
  • While the Proxy itself is a good idea, I need something that is more transparent. Setting the HTTP-Proxy on every client doesn't do that. Perhaps I can do something on my DD-WRT router? Something like. Forward IP_HUE:80 -> IP_PI:1234 and Forward IP_HUE:8080 -> IP_HUE:80? so trying to reach the hue bridge ends up on the Pi while the hue bridge can still be reached using another port? – kwasmich Nov 12 '16 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.