3 # Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
4 # Version 1.0 - 20191227
6 # Create a new user on the bridge
9 # $ add-newdeveloper.py <bridge IP>
11 # Follow the steps at the Hue Developer site to get the username/token
12 # https://developers.meethue.com/develop/get-started-2/
22 parser = argparse.ArgumentParser(description="Create a new developer token on the Hue Bridge")
23 parser.add_argument("bridge", type=str, help="Hue Bridge IP address")
26 args = parser.parse_args()
29 except argparse.ArgumentError as e:
32 no_cert_check = ssl.create_default_context()
33 no_cert_check.check_hostname=False
34 no_cert_check.verify_mode=ssl.CERT_NONE
36 data = b'{"devicetype": "my_hue_app#device"}'
37 url = f"https://{bridge}/api"
38 req = urllib.request.Request(url=url, data=data, method='POST')
39 with urllib.request.urlopen(req, context=no_cert_check) as response:
40 content = response.read()
41 json_data = json.loads(content)
42 print (f"{json_data}")