commit - a50be9a2ffd86052eee424012fa7ef90076d16f7
commit + b455762fa20af256019440e420831946f8fab374
blob - /dev/null
blob + 6377fc0ab36c8ce44977b2c2b095d404fd6b43a5 (mode 755)
--- /dev/null
+++ add-newdeveloper.py
+#!/usr/bin/env python3
+#
+# Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
+# Version 1.0 - 20191227
+#
+# Create a new user on the bridge
+#
+# For example:
+# $ create-new.py <bridge IP>
+#
+# Follow the steps at the Hue Developer site to get the username/token
+# https://developers.meethue.com/develop/get-started-2/
+#
+# Requires:
+# - Python >3.6
+#
+import argparse
+import ssl
+import urllib.request
+import json
+
+parser = argparse.ArgumentParser(description="Control light")
+parser.add_argument("bridge", type=str, help="Hue Bridge IP")
+
+try:
+ args = parser.parse_args()
+ bridge = args.bridge
+
+except argparse.ArgumentError as e:
+ print(str(e))
+
+no_cert_check = ssl.create_default_context()
+no_cert_check.check_hostname=False
+no_cert_check.verify_mode=ssl.CERT_NONE
+
+data = b'{"devicetype": "my_hue_app#device"}'
+url = f"https://{bridge}/api"
+req = urllib.request.Request(url=url, data=data, method='POST')
+with urllib.request.urlopen(req, context=no_cert_check) as response:
+ content = response.read()
+json_data = json.loads(content)
+print (f"{json_data}")