def fingerprint(args) -> None: """Save the vehicle fingerprint.""" time_dir = Path.home() / 'vehicle_fingerprint' / time.strftime( "%Y-%m-%d_%H-%M-%S") time_dir.mkdir(parents=True) account = ConnectedDriveAccount(args.username, args.password, get_region_from_name(args.region), log_responses=time_dir) if args.lat and args.lng: for vehicle in account.vehicles: vehicle.set_observer_position(args.lat, args.lng) # doesn't work anymore # account.update_vehicle_states() # Patching in new My BMW endpoints for fingerprinting server_url = get_server_url(get_region_from_name(args.region)) for vehicle in account.vehicles: if vehicle.drive_train in HV_BATTERY_DRIVE_TRAINS: print("Getting 'charging-sessions' for {}".format(vehicle.vin)) account.send_request( "https://{}/eadrax-chs/v1/charging-sessions".format( server_url), params={ "vin": vehicle.vin, "maxResults": 40, "include_date_picker": "true" }, logfilename="charging-sessions") print("Getting 'charging-statistics' for {}".format(vehicle.vin)) account.send_request( "https://{}/eadrax-chs/v1/charging-statistics".format( server_url), params={ "vin": vehicle.vin, "currentDate": datetime.utcnow().isoformat() }, logfilename="charging-statistics") print('fingerprint of the vehicles written to {}'.format(time_dir))
def server_url(self) -> str: """Get the url of the server for this country.""" if self._server_url is None: self._server_url = get_server_url(self._region) return self._server_url