def test_get_lock_detail_bridge_offline(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="ABC"), text=load_fixture("get_lock.offline.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "ABC") self.assertEqual("ABC", lock.device_id) self.assertEqual("Test", lock.device_name) self.assertEqual("houseid", lock.house_id) self.assertEqual("ABC", lock.serial_number) self.assertEqual("undefined-1.59.0-1.13.2", lock.firmware_version) self.assertEqual(-100, lock.battery_level) self.assertEqual("AUG-X", lock.model) self.assertEqual(False, lock.bridge_is_online) self.assertEqual(None, lock.keypad) self.assertEqual(None, lock.bridge) self.assertEqual(False, lock.doorsense) self.assertEqual(LockStatus.UNKNOWN, lock.lock_status) self.assertEqual(LockDoorStatus.UNKNOWN, lock.door_state) self.assertEqual(None, lock.lock_status_datetime) self.assertEqual(None, lock.door_state_datetime)
def test_get_lock_detail_with_doorsense_bridge_online(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="ABC"), text=load_fixture("get_lock.online_with_doorsense.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "ABC") self.assertEqual("ABC", lock.device_id) self.assertEqual("Online door with doorsense", lock.device_name) self.assertEqual("123", lock.house_id) self.assertEqual("XY", lock.serial_number) self.assertEqual("undefined-4.3.0-1.8.14", lock.firmware_version) self.assertEqual(92, lock.battery_level) self.assertEqual("AUG-MD01", lock.model) self.assertEqual(None, lock.keypad) self.assertIsInstance(lock.bridge, BridgeDetail) self.assertIsInstance(lock.bridge.status, BridgeStatusDetail) self.assertEqual(BridgeStatus.ONLINE, lock.bridge.status.current) self.assertEqual(True, lock.bridge_is_online) self.assertEqual(True, lock.bridge.operative) self.assertEqual(True, lock.doorsense) self.assertEqual(LockStatus.LOCKED, lock.lock_status) self.assertEqual(LockDoorStatus.OPEN, lock.door_state) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.lock_status_datetime ) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.door_state_datetime )
def test_get_lock_detail_bridge_online(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="A6697750D607098BAE8D6BAA11EF8063"), text=load_fixture("get_lock.online.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "A6697750D607098BAE8D6BAA11EF8063") self.assertEqual("A6697750D607098BAE8D6BAA11EF8063", lock.device_id) self.assertEqual("Front Door Lock", lock.device_name) self.assertEqual("000000000000", lock.house_id) self.assertEqual("X2FSW05DGA", lock.serial_number) self.assertEqual("109717e9-3.0.44-3.0.30", lock.firmware_version) self.assertEqual(88, lock.battery_level) self.assertEqual("AUG-SL02-M02-S02", lock.model) self.assertEqual("Medium", lock.keypad.battery_level) self.assertEqual(60, lock.keypad.battery_percentage) self.assertEqual("5bc65c24e6ef2a263e1450a8", lock.keypad.device_id) self.assertIsInstance(lock.bridge, BridgeDetail) self.assertEqual(True, lock.bridge_is_online) self.assertEqual(True, lock.bridge.operative) self.assertEqual(True, lock.doorsense) self.assertEqual(LockStatus.LOCKED, lock.lock_status) self.assertEqual(LockDoorStatus.CLOSED, lock.door_state) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.lock_status_datetime ) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.door_state_datetime )
def test_get_lock_detail(self, mock): mock.register_uri("get", API_GET_LOCK_URL.format( lock_id="A6697750D607098BAE8D6BAA11EF8063"), text=load_fixture("get_lock.json")) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "A6697750D607098BAE8D6BAA11EF8063") self.assertEqual("A6697750D607098BAE8D6BAA11EF8063", lock.device_id) self.assertEqual("Front Door Lock", lock.device_name) self.assertEqual("000000000000", lock.house_id) self.assertEqual("X2FSW05DGA", lock.serial_number) self.assertEqual("109717e9-3.0.44-3.0.30", lock.firmware_version) self.assertEqual(88, lock.battery_level)
authentication = authenticator.authenticate() # State can be either REQUIRES_VALIDATION, BAD_PASSWORD or AUTHENTICATED # You'll need to call different methods to finish authentication process, see below state = authentication.state #print( state ) # If AuthenticationState is BAD_PASSWORD, that means your login_method, username and password do not match # If AuthenticationState is AUTHENTICATED, that means you're authenticated already. If you specify "access_token_cache_file", the authentication is cached in a file. Everytime you try to authenticate again, it'll read from that file and if you're authenticated already, Authenticator won't call August again as you have a valid access_token if state == AuthenticationState.REQUIRES_VALIDATION: # If AuthenticationState is REQUIRES_VALIDATION, then you'll need to go through verification process # send_verification_code() will send a code to either your phone or email depending on login_method authenticator.send_verification_code() # Wait for your code and pass it in to validate_verification_code() validation_result = authenticator.validate_verification_code(input()) # If ValidationResult is INVALID_VERIFICATION_CODE, then you'll need to either enter correct one or resend by calling send_verification_code() again # If ValidationResult is VALIDATED, then you'll need to call authenticate() again to finish authentication process authentication = authenticator.authenticate() # Once you have authenticated and validated you can use the access token to make API calls locks = api.get_locks(authentication.access_token) #print (locks[0].device_id) #api.unlock(authentication.access_token, locks[0].device_id) api.get_lock_detail(authentication.access_token, locks[0].device_id)