A collection of Firebase Cloud functions to report the car status using Tesla Unofficial API
I set up this repo with my Raspberry Pi as a cronjob to report the status of the vehicle very 30 minutes.
(Replace /home/pi/tesla-client
to your installation folder)
- Clone this repository
git clone https://github.com/aduyng/tesla-client.git /home/pi/tesla-client
- Install dependencies
cd /home/pi/tesla-client [sudo] npm install forever --global npm install --production
- Follow the instruction here: https://firebase.google.com/docs/admin/setup to set up your firebase project and obtain the parameters for
initializeApp()
. Download the service account JSON file and save it to/home/pi/tesla-client/private/firebase-service-account-key.json
- Enter environment variables in
/home/pi/tesla-client/.env
TESLA_CLIENT_ID=<the tesla client id as instructed here https://tesla-api.timdorr.com/api-basics/authentication> TESLA_CLIENT_SECRET=<the tesla client secret> TESLA_ACCOUNT_USERNAME=<owner email address> TESLA_ACCOUNT_PASSWORD=<owner password> FIREBASE_API_KEY=<firebase apiKey> FIREBASE_AUTH_DOMAIN=<firebase authDomain> FIREBASE_DATABASE_URL=<firebase databaseURL> FIREBASE_PROJECT_ID=<firebase projectId> FIREBASE_STORAGE_BUCKET=<firebase storageBucket> FIREBASE_MESSAGING_SENDER_ID=<firebase messagingSenderId> FIREBASE_APP_ID=<firebase appId> GOOGLE_APPLICATION_CREDENTIALS=/home/pi/tesla-client/private/firebase-service-account-key.json CRON_SCHEDULE="*/5 * * * *"
- Start with
forever
forever start /home/pi/tesla-client/forever.json
Run npm run dev
to start the development