Using excess solar charger from my solar setup with sungrow inverter to charge my tesla model y. It's very much experimental for now.
Go to Tesla Developer Dashboard and create a tesla application.
- Copy example.env to .env
- Modify .env and update all the credentials and config
This is needed to run vehicle commands on behalf of a certain tesla user. It's based on OAuth2.
- Generate login URI
npm run cmd:generate-refresh-token
-
Login using tesla credentials
-
Copy the authorization code from the URI Example:
http://localhost:4321/tesla-charger?locale=en-US&code=NA_9e160ae8108f48287d1c28b40a410c4344ea3dc802483002a920bdf52dc2&state=xdfk76qcqysnf4s4rqhy&issuer=https%3A%2F%2Fauth.tesla.com%2Foauth2%2Fv3
- Copy the value of the parameter
code
- Run generate-token again but with the code obtained in the last step like
npm run cmd:generate-refresh-token NA_9e160ae8108f48287d1c28b40a410c4344ea3dc802483002a920bdf52dc2
- Obtain the value of refresh token in the JSON and paste the value of refresh token in
.env
like
TESLA_OAUTH2_REFRESH_TOKEN=NA_sdfgslitrvhnoweitunheroituhewrotiuehrmtylibuerhnyoilertuye
- Call endpoint POST /api/1/partner_accounts in Tesla's fleet API and make sure all it's pre-requisites are met including
- Generating private-public key pair for using the tesla vehicle command sdk.
- Upload public key to
.well-known
directory under the required path.
- Go to https://www.tesla.com/_ak/domain.com and follow the instructions
SunGather is a tool to Collect data from Sungrow Inverters and export data to various locations. For this project, you just need to setup SunGather to write two data points
- export_to_grid
- import_to_grid
In theory, you could easily use this without SunGather and for any inverters as long as you can find a way to write those two values in the configured bucket.
npm run dev