#NEWLINE# def connect( self ) : #NEWLINE# #INDENT# '\n        Registers a new device + username with the bridge\n        ' #NEWLINE# if self . validate_registration ( ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# body = { #NEWLINE# #INDENT# 'devicetype' : self . device_type , #NEWLINE# 'username' : self . username , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . make_request ( 'POST' , '/api' , body ) #NEWLINE# if ( 'error' in response ) : #NEWLINE# #INDENT# if ( response [ 'error' ] [ 'type' ] == 101 ) : #NEWLINE# #INDENT# msg = 'Please press the link button and try again' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = response [ 'error' ] [ 'description' ] #NEWLINE# #UNINDENT# raise Exception ( msg )