Python script to import fuel fill-ups from Fuelio's Google Drive backups to Lubelogger.
Defaults:
- The log level set in the execution args (
--log-level
) takes presedence over config.yml'slog_level
. If neither are set, it will default toINFO
. - If
config_dir
is unspecified, the default is to look for a directory namedconfig
in the script's current working direcory.
It can also be set by defining theCONFIG_DIR
environment variable.
python3 main.py [-h|--help] [--dry-run] [--log-level {debug,info,warning,error,critical}] [config_dir]
docker run --rm -v ./config:/app/config ghcr.io/tigattack/lubelogger-fuelio-importer:latest [--dry-run]
docker compose up [-d]
Tip
You will need to download docker-compose.yml to current directory before running.
First, a couple of prerequisites:
- Fuelio must be configured to back up to Google Drive (docs).
- You must generate service or client credentials for the Google Drive API. Client credentials require interactive (browser) authentication, while service accounts do not. Pick the most appropriate option for your case and follow the instructions in the relevant sections below.
Now you can complete the configuration for the importer:
- Copy
config.example.yml
toconfig.yml
, and open it in an editor. - Define your vehicle('s) IDs in Fuelio & Lubelogger.
- Set your Lubelogger domain, username, and password.
- Set your Google Drive folder ID (see instructions below).
- Create your Google authentication credentials JSON (see instructions below) and move the file in place
- Set your credentials filename and the relevant
auth_type
in the config. - Run the importer per the Usage section above.
Fuelio vehicle IDs are chronological, i.e. the first vehicle you add to Fuelio is ID 1, the second is ID 2, and so on.
If you're unsure, download and extract the backup ZIP of each vehicle and inspect the CSV inside.
- Open Lubelogger in a browser.
- Navigate to the vehicle in question.
- The vehicle ID will be in the URL like so:
https://lubelogger.domain.tld/Vehicle/Index?vehicleId=<vehicle ID here>
- Open Google Drive in a browser.
- Navigate to the folder in which Fulio stores its backups.
- The folder ID will be in the URL like so:
https://drive.google.com/drive/folders/<folder ID here>
- Go to APIs Console and make your own project.
- Search for "Google Drive API", select the entry, and click "Enable".
- Based on the authentication type you've chosen, follow the relevant set of instructions below.
- Click Create Credentials at https://console.cloud.google.com/apis/credentials
- Select "OAuth client ID".
- Now, the product name and consent screen need to be set -> click "Configure consent screen" and follow the instructions. Once finished:
- Select "Application type" to be Web application.
- Enter an appropriate name.
- Input http://localhost:8080/ for "Authorized redirect URIs".
- Click "Create".
- Click "Download JSON" on the right side of Client ID to download
client_secret_<really long ID>.json
. - The downloaded file has all authentication information of your application. Rename the file to “client_secrets.json” and place it in your working directory.
- Click Create Credentials at https://console.cloud.google.com/apis/credentials
- Select "Service Account".
- Enter an appropriate name.
- Continue through steps 2 & 3.
- Select the service account in the list.
- Copy the service account's email address. We'll use this later.
- Select the "Keys" tab and create a new key:
- Click "Add key"
- Select "Create new key"
- Select "JSON"
- Click "Create"
- The service account key will be downloaded. Rename the file to "service_secrets.json" and place it in your working directory.
- Open Google Drive in a browser.
- Navigate to the folder in which Fulio stores its backups.
- Share the folder with the service account using email address you copied in step 6. The "Viewer" role is all it needs.