forked from hahn-th/homematicip-rest-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_auth_token.py
34 lines (26 loc) · 963 Bytes
/
generate_auth_token.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import homematicip
import time
while True:
access_point = raw_input("Please enter the accesspoint id (SGTIN): ").replace('-', '').upper()
if len(access_point) != 24:
print "Invalid access_point id"
continue
break
pin = raw_input("Please enter the PIN (leave Blank if there is none): ")
devicename = raw_input("Please enter the client/devicename (leave blank to use default):")
homematicip.init(access_point)
auth = homematicip.Auth()
if pin != '':
auth.pin=pin
if devicename != '':
auth.connectionRequest(access_point,devicename)
else:
auth.connectionRequest(access_point)
print "Please press the blue button on the access point"
while not auth.isRequestAcknowledged():
print "Please press the blue button on the access point"
time.sleep(2)
auth_token = auth.requestAuthToken()
clientId = auth.confirmAuthToken(auth_token)
print "Token successfully registered: ", auth_token
print "Client ID is ", clientId