diff --git a/README.md b/README.md index e479631..228bf89 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Tesla HTTP Proxy Docker -** Pleae use release version v1.0.3 until I can investigate a problem reported with v1.0.4 (https://github.com/iainbullock/tesla-http-proxy-docker/issues/19). Dockerhub 'latest' tag withdrawn until next release ** - Now tested and working as expected with Home Assistant custom integration https://github.com/alandtse/tesla Originally this was a fork of https://github.com/llamafilm/tesla-http-proxy-addon. All credit to llamafilm (https://github.com/llamafilm) for developing most of this. @@ -29,13 +27,22 @@ Setting this up is fairly complex. Please read [DOCS.md](./tesla_http_proxy/DOC - Start the container again. Further configuration will occur, and the Flask service will start to handle the creation of the vehicle keypair with Tesla and installing the key into your vehicle - - Enter the URL of your FQDN into a web browser. A page titled 'Tesla HTTP Proxy setup' will appear. Click the 'Generate OAuth token' button. This will open another web page inviting you to login into to Tesla. You will then be offered to allow the application to access your Tesla account. Click all the check boxes and press the Allow button + - Enter the URL of your FQDN into a web browser. A page titled 'Tesla HTTP Proxy setup' will appear. Click the '1. Generate OAuth token' button. This will open another web page inviting you to login into to Tesla. You will then be offered to allow the application to access your Tesla account. Click all the check boxes and press the Allow button - - The callback will then occur which if successful will display a page saying 'Authorization complete'. Click the 'You can now close this browser instance' button + - The callback will then occur which if successful will display a page saying 'Authorization complete'. The has generated a public/private key pair for Tesla Vehicle Commands, and the initial Access and Refresh tokens for the API access. Click the 'You can now close this browser instance' button - - Return to the 'Tesla HTTP Proxy setup' page. Click the 'Enroll public key in your vehicle' button. Another Tesla web page will appear inviting you to set up a third party virtual key. There is a QR code which you should scan with your phone (which already has the Tesla App installed and setup for your Tesla account). Approve the key in the Tesla app, which if successful will install it into your vehicle. You can close this webpage + - Return to the 'Tesla HTTP Proxy setup' page. Click the '2. Test public key endpoint' button. This will download the public key (com.tesla.3p.public-key.pem). You don't need to keep the downloaded key. You must keep this accessible to the internet or Tesla will reject your commands made through the proxy. You may have to manually copy the public key to a suitable location in the document root on your webserver. Make sure this test works before proceeding - - Return to the 'Tesla HTTP Proxy setup' page. Click the 'Test public key endpoint' button. This will download the public key (the private key was installed into you car). You don't need it, but you must keep this accessible to the internet or Tesla will reject your commands made through the proxy + - Return to the 'Tesla HTTP Proxy setup' page. Click the '3. Register Partner account' button. This generates the Partner Authentication token, and registers the account for API access. There isn't any feedback whether this works or not. Check the logs you will see something like this: + +[16:14:02] main:INFO: *** Generating Partner Authentication Token *** +[16:14:03] main:INFO: {"access_token":"LongString","expires_in":28800,"token_type":"Bearer"} +[16:14:03] main:INFO: *** Registering Tesla account *** +[16:14:05] main:INFO: {"response":{"account_id":"XXXX-XXX-XXXX-XXX","domain":"tesla.example.com","name":"TeslaH","description":"Home automation for my Tesla. Application is for personal use only","csr":null,"client_id":"XX-XXXX-XX-XXXXXXXXXX","ca":null,"created_at":"2024-02-28T13:50:49.494Z","updated_at":"2024-04-07T16:14:05.827Z","enterprise_tier":"free","issuer":null,"csr_updated_at":null,"public_key":"FairlyLongString"}} +[16:14:05] werkzeug:INFO: 192.168.1.5 - - [07/Apr/2024 16:14:05] "GET /register-partner-account HTTP/1.0" 302 - +[16:14:05] werkzeug:INFO: 192.168.1.5 - - [07/Apr/2024 16:14:05] "GET /?success=1 HTTP/1.0" 200 - + + - Return to the 'Tesla HTTP Proxy setup' page. Click the '4. Enrol private key into your vehicle' button. Another Tesla web page will appear inviting you to set up a third party virtual key. There is a QR code which you should scan with your phone (which already has the Tesla App installed and setup for your Tesla account). Approve the key in the Tesla app, which if successful will install it into your vehicle. You can close this webpage - Return to the 'Tesla HTTP Proxy setup' page. Click 'Shutdown Flask Server'. This will do as it says. From now on the proxy server will continue to run in the docker contianer and listen for requests diff --git a/tesla_http_proxy/app/curl/test.sh b/tesla_http_proxy/app/curl/test.sh index 453df1c..ff7fecd 100644 --- a/tesla_http_proxy/app/curl/test.sh +++ b/tesla_http_proxy/app/curl/test.sh @@ -1,6 +1,5 @@ #!/bin/bash #export TESLA_AUTH_TOKEN=XXXXXXXX -#export VIN=xxxxxxxxxxxxxxxxx curl --cacert ../cert.pem \ --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \ diff --git a/tesla_http_proxy/app/run.sh b/tesla_http_proxy/app/run.sh index c252d31..5f40c10 100755 --- a/tesla_http_proxy/app/run.sh +++ b/tesla_http_proxy/app/run.sh @@ -56,7 +56,7 @@ elif [ ! -f /share/nginx/com.tesla.3p.public-key.pem ]; then generate_tesla_keypair fi -if [ -f /share/home-assistant/selfsigned.pem ]; then +if [ -f /share/home-assistant/selfsigned.pem ] && [ -f /data/key.pem ]; then certPubKey="$(openssl x509 -noout -pubkey -in /share/home-assistant/selfsigned.pem)" keyPubKey="$(openssl pkey -pubout -in /data/key.pem)" if [ "${certPubKey}" == "${keyPubKey}" ]; then diff --git a/tesla_http_proxy/app/templates/index.html b/tesla_http_proxy/app/templates/index.html index 95b180c..cec79f3 100644 --- a/tesla_http_proxy/app/templates/index.html +++ b/tesla_http_proxy/app/templates/index.html @@ -35,11 +35,11 @@