added script to create new developer, clip.html wasn't working
This commit is contained in:
parent
a50be9a2ff
commit
b455762fa2
42
add-newdeveloper.py
Executable file
42
add-newdeveloper.py
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/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}")
|
Loading…
Reference in New Issue
Block a user