studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.53k stars 266 forks source link

Multiple Hubs #54

Open lespatots opened 9 years ago

lespatots commented 9 years ago

I have two hubs and using this in HA, it finds all the bulbs once the hubs are registered. However on subsequebt start, one of the hubs is 'lost' and needs re-registering. I see there is just one entry in the phue.conf file so that is the problem. Either the file needs to accomodate additional registration entries or more than one file. As the number of hubs is likely to be low could the registration process store all the user ids in the one file and try all the keys to establish a match or match the key to the IP address?

natcl commented 9 years ago

Did you try specifying your api_key directly in the code ?

You should be able to do something like this:

bridge1 = Bridge('192.168.1.10', 'keyofbridge1')
bridge2 = Bridge('192.168.1.11', 'keyofbridge2')

Let me know if it works...

lespatots commented 9 years ago

Hi,

Thanks for the reply. I did have a look at phue.py and to be honest whilst I can see some code that is used to collect the key from the bridge when the button is pressed I couldn’t actually pin down where the filename phue.conf comes from. I’ve never programmed in python, I manage ‘c' on an Arduino but at 65 I don’t think I can learn python sufficiently to offer code good enough for real use. In any event, whilst perhaps directly putting the key in the code would be good for a test it’s not a good end solution for general application. Also, probably because I don’t understand Python how does bridge1 and bridge2 get used in the right places and where would I put this code?

I think the best way would be to store keys alongside the IP address in the phue.conf file and to look up the key when needed, which is surely only when the bridge asks for one? It might be that the IP address is the wrong bridge identifier in a DHCP regime so there does need to be some thinking done by people cleverer than me to address this?

Also does one then need to identify Hue objects with unique names or would Python somehow create a list of which lights are in which bridge and handle the issue of the name Lamp 1 existing in multiple bridges?

On 17 Sep 2015, at 16:18, Nathanaël Lécaudé tifications@github.com> wrote:

Did you try specifying your api_key directly in the code ?

You should be able to do something like this:

bridge1 = Bridge('192.168.1.10', 'keyofbridge1') bridge2 = Bridge('192.168.1.11', 'keyofbridge2') Let me know if it works...

— Reply to this email directly or view it on GitHub https://github.com/studioimaginaire/phue/issues/54#issuecomment-141101395.