I am working on Android project that utilises that Philips Hue SDK.
I've implemented some of the functionality so that I can successfully control the lights but I am also trying to make the app control the lights when the user is away from home.
I have set up port forwarding so that I can connect to my public IP address through port 80 and it forwards it to the bridge.
The idea is that the user connects to the bridge and authenticates with the bridge on its local ip addresss. The user is then able to enter what the external address is.
I have a function that when connecting to the bridge, I check to see if the user connected Wifi and are they on their own home wifi I then set the IP address of the PHAccessPoint of the users local bridge bridge address.
If the user is not on wifi, or they are but on the home wifi, then the PHAccessPoint IP address is updated to what the user entered as they're external address.
When I do this, I keep getting either Bridge not responding, not connected or bridge already connected and this keeps happening rapidly. Even though in the error handler, if I get bridge not responding or not connected, I ensure I disconnect the PHAccessPoint and attempt to re-connect again.
I've tried disabling the Heartbeat Interval or increasing it and it makes no difference.
If however I am on the wifi but still connect via my public IP address it works, I only get this problem if going through mobile data.
Are there any tricks to make this work I've seen other apps do something similar but its not open source so can't see how they've implemented it.
I have signed up to Philips Hue Remote API, but I've had no response from them.
The Hue bridge cannot change the port it is listening on (ie. port 80) unfortunately.
The Hue Bridge connects to any available Ethernet port on your wireless router using an Ethernet cable. Plug the provided Ethernet cable into the Bridge and the opposite end into an open Ethernet slot on your router. Once the four lights on the Bridge light up, it is ready to set up.
Supported Things The Hue bridge is required as a "bridge" for accessing any other Hue device. It supports the ZigBee LightLink protocol as well as the upwards compatible ZigBee 3.0 protocol. There are two types of Hue bridges, generally referred to as v1 (the rounded version) and v2 (the squared version).
The Philips Hue bridge uses the Zigbee Light Link standard, which makes it, according to Philips, compatible to all such light bulbs and devices.
After lots of trial and error and Android Studio being able to decompile the SDK so I can see some of the code I think its a limitation of how the official SDK is implemented.
Basically I think the problem is that you create a PHAccessPoint object and set your external ip e.g. 86.85.84.83, when you connect to the bridge, you successfully connect and get the bridge details, and it stores the bridge configuration as a PHBridge object. This object contains the bridge's local network IP e.g. 192.168.x.x. When you then come to do anything else the connected bridge object and the PHAccessPoint object don't match and therefore a no connection error is returned, upon trying to handle that and re-connect, because the SDK has a bridge set up as connected the SDK returns that you are already connected and you end up getting stuck in a loop.
I think the only way around this would be to either have a server that is exposed via port forwarding and the messages are passed on from the server to the local bridge and then back out though the server (so the actual bridge stays local) or to roll your own implementation of the SDK using the RESTful API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With