I have had a working program to control my Hue lights for a while, and have recently transferred to a new PC. I went to get it setup, and I received a few errors that I can't work out the reason why they are happening, as the code worked perfectly fine on my old machine.
My Code:
f = open("first.json", "r")
data = json.loads(f.read())
f.close()
login = [index["username"] for index in data]
bridge_ip = [index["bridge_ip"] for index in data]
login = ",".join(login)
bridge_ip = ",".join(bridge_ip)
get_address = "https://%s/api/%s/lights" % (bridge_ip, login)
r_lights = requests.get(get_address)
Errors:
Traceback (most recent call last):
File "C:\Users\Andrew\Desktop\HueProgram\huepy.py", line 69, in <module>
r_lights = requests.get(get_address)
File "C:\Users\Andrew\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Andrew\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Andrew\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Andrew\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Andrew\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\adapters.py", line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.1.102', port=443): Max retries exceeded with url: /api/Usba0ripFRGZvGIuhLdFEtnHZBLG-NFhpIEeZ7-B/lights (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x040D89B0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))