#NEWLINE# def validate_api( api ) : #NEWLINE# #INDENT# 'Make a call to validate API.' #NEWLINE# try : #NEWLINE# #INDENT# req = api ( METHOD_GET , URL_API ) #NEWLINE# if ( req . status_code == 200 ) : #NEWLINE# #INDENT# return APIStatus . OK #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( req . status_code == 401 ) : #NEWLINE# #INDENT# return APIStatus . INVALID_PASSWORD #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return APIStatus . UNKNOWN #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except HomeAssistantError : #NEWLINE# #INDENT# return APIStatus . CANNOT_CONNECT