├── tesla_http_proxy
├── app
│ ├── curl
│ │ ├── test.sh
│ │ ├── fart.sh
│ │ └── open_boot.sh
│ ├── config.sh
│ ├── templates
│ │ ├── callback.html
│ │ └── index.html
│ ├── run.sh
│ └── run.py
├── README.md
├── CHANGELOG.md
├── CLOUDFLARE.md
└── DOCS.md
├── .github
├── workflows
│ ├── dockerhub-description.yml
│ ├── builddev.yml
│ └── build.yml
└── FUNDING.yml
├── Dockerfile
├── nginx_tesla.conf
├── docker-compose.yml
├── README.md
└── LICENSE
/tesla_http_proxy/app/curl/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #export TESLA_AUTH_TOKEN=XXXXXXXX
3 |
4 | curl --cacert ../cert.pem \
5 | --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \
6 | "https://$PROXY_HOST:4430/api/1/vehicles"
7 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/curl/fart.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #TESLA_AUTH_TOKEN=XXXXXX
3 | #VIN=xxxxxxxxxxxxxxxxx
4 |
5 | curl --cacert ../cert.pem \
6 | --header 'Content-Type: application/json' \
7 | --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \
8 | --data '{"sound": "1"}' \
9 | "https://$PROXY_HOST:4430/api/1/vehicles/$VIN/command/remote_boombox"
10 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/curl/open_boot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #TESLA_AUTH_TOKEN=XXXXXX
3 | #VIN=xxxxxxxxxxxxxxxxx
4 |
5 | curl --cacert ../cert.pem \
6 | --header 'Content-Type: application/json' \
7 | --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \
8 | --data '{"which_trunk": "rear"}' \
9 | "https://$PROXY_HOST:4430/api/1/vehicles/$VIN/command/actuate_trunk"
10 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/ash
2 | # Enter values for your particular configuration here
3 | CLIENT_ID='client_id'
4 | CLIENT_SECRET='client_secret'
5 | DOMAIN='tesla.example.com' # Public FQDN
6 | PROXY_HOST='hostname.local' # Local hostname (not IP) of this docker host
7 | REGION='Europe, Middle East, Africa' # Change to match your region
8 | # Change this to OPTIONS_COMPLETE=1 when ready to run
9 | OPTIONS_COMPLETE=0
10 |
--------------------------------------------------------------------------------
/tesla_http_proxy/README.md:
--------------------------------------------------------------------------------
1 | # Home Assistant Add-on: Tesla HTTP Proxy
2 |
3 | This add-on runs the official [Tesla HTTP Proxy](https://github.com/teslamotors/vehicle-command) to allow Fleet API requests on modern vehicles. Please do not bother Tesla for support on this.
4 |
5 | ## About
6 | Runs a temporary Flask web server to handle initial Tesla authorization flow and store the refresh token. Once that is complete, it quits Flask and runs Tesla's HTTP Proxy code in Go.
7 |
8 | Setting this up is fairly complex. Please read [DOCS.md](./DOCS.md) for details.
9 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/templates/callback.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 | Authorization complete
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.github/workflows/dockerhub-description.yml:
--------------------------------------------------------------------------------
1 | name: Update Docker Hub Description
2 | on:
3 | push:
4 | branches:
5 | - main
6 | paths:
7 | - README.md
8 | - .github/workflows/dockerhub-description.yml
9 | jobs:
10 | dockerHubDescription:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v4
14 |
15 | - name: Docker Hub Description
16 | uses: peter-evans/dockerhub-description@v4
17 | with:
18 | username: ${{ secrets.DOCKER_USER }}
19 | password: ${{ secrets.DOCKER_PASSWORD }}
20 | repository: iainbullock/tesla_http_proxy
21 | short-description: ${{ github.event.repository.description }}
22 | enable-url-completion: true
23 |
--------------------------------------------------------------------------------
/tesla_http_proxy/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## 1.2.2
4 |
5 | ### Changed
6 |
7 | - Support all 3 Fleet API regions
8 | - Colored output to help configuration of `tesla_custom` integration
9 |
10 | ## 1.2.0
11 |
12 | ### Changed
13 |
14 | - Remove unnecessary VIN from config
15 | - Add `regenerate_auth` config option to help with OAuth testing
16 | - Expose ports 443 and 8099 to support external reverse proxies
17 | - Improved error handling when add-on is restarted
18 |
19 | ## 1.1.0
20 |
21 | ### Changed
22 |
23 | - Skip auth flow if already completed
24 | - Print `refresh_token` to the log
25 | - Correct CN for SSL cert
26 |
27 | ## 1.0.0
28 |
29 | - Initial release
30 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | polar: # Replace with a single Polar username
13 | buy_me_a_coffee: iainbullock
14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.25-alpine3.22 AS build
2 |
3 | RUN apk add --no-cache \
4 | unzip
5 |
6 | RUN mkdir -p /app/bin
7 | # install Tesla Go packages
8 | ADD https://github.com/teslamotors/vehicle-command/archive/refs/heads/main.zip /tmp
9 | RUN unzip /tmp/main.zip -d /app
10 | WORKDIR /app/vehicle-command-main
11 | RUN go get ./...
12 | RUN go build -o /app/bin ./...
13 |
14 | FROM alpine:3.19.1
15 |
16 | # install dependencies
17 | RUN apk add --no-cache \
18 | python3 \
19 | py3-flask \
20 | py3-requests \
21 | gpg-agent \
22 | pass \
23 | openssl
24 |
25 | # Create various working directories
26 | RUN mkdir /data /share
27 |
28 | # Copy project files into required locations
29 | COPY tesla_http_proxy/app /app
30 |
31 | # Copy tesla-http-proxy binary from build stage
32 | COPY --from=build /app/bin/tesla-http-proxy /app/bin/tesla-keygen /usr/bin/
33 |
34 | # Set environment variables
35 | ENV GNUPGHOME="/data/gnugpg"
36 | ENV PASSWORD_STORE_DIR="/data/password-store"
37 |
38 | # Python 3 HTTP Server serves the current working dir
39 | WORKDIR /app
40 |
41 | ENTRYPOINT ["/app/run.sh"]
42 |
--------------------------------------------------------------------------------
/.github/workflows/builddev.yml:
--------------------------------------------------------------------------------
1 | name: Build container image
2 |
3 | on:
4 | release:
5 | types: [prereleased]
6 |
7 | permissions:
8 | contents: read
9 | packages: write
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4.1.1
17 |
18 | - name: Set up QEMU
19 | uses: docker/setup-qemu-action@v3.0.0
20 |
21 | - name: Set up Docker Buildx
22 | uses: docker/setup-buildx-action@v3.2.0
23 |
24 | - name: Login to GitHub Container Registry
25 | uses: docker/login-action@v3.1.0
26 | with:
27 | registry: ghcr.io
28 | username: ${{ github.actor }}
29 | password: ${{ secrets.GITHUB_TOKEN }}
30 |
31 | - name: Log in to docker hub
32 | uses: docker/login-action@v3.1.0
33 | with:
34 | username: ${{ secrets.DOCKER_USER }}
35 | password: ${{ secrets.DOCKER_PASSWORD }}
36 |
37 | - name: Build and push
38 | uses: docker/build-push-action@v5.3.0
39 | with:
40 | context: .
41 | file: ./Dockerfile
42 | platforms: linux/amd64
43 | cache-from: type=gha
44 | cache-to: type=gha,mode=max
45 | push: true
46 | tags: |
47 | ghcr.io/${{ github.repository }}:latest
48 | ghcr.io/${{ github.repository }}:${{ github.sha }}
49 | docker.io/iainbullock/tesla_http_proxy:dev
50 | docker.io/iainbullock/tesla_http_proxy:${{ github.ref_name }}
51 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build container image
2 |
3 | on:
4 | release:
5 | types: [released]
6 |
7 | permissions:
8 | contents: read
9 | packages: write
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4.1.1
17 |
18 | - name: Set up QEMU
19 | uses: docker/setup-qemu-action@v3.0.0
20 |
21 | - name: Set up Docker Buildx
22 | uses: docker/setup-buildx-action@v3.2.0
23 |
24 | - name: Login to GitHub Container Registry
25 | uses: docker/login-action@v3.1.0
26 | with:
27 | registry: ghcr.io
28 | username: ${{ github.actor }}
29 | password: ${{ secrets.GITHUB_TOKEN }}
30 |
31 | - name: Log in to docker hub
32 | uses: docker/login-action@v3.1.0
33 | with:
34 | username: ${{ secrets.DOCKER_USER }}
35 | password: ${{ secrets.DOCKER_PASSWORD }}
36 |
37 | - name: Build and push
38 | uses: docker/build-push-action@v5.3.0
39 | with:
40 | context: .
41 | file: ./Dockerfile
42 | platforms: linux/amd64,linux/arm64,linux/arm/v7
43 | cache-from: type=gha
44 | cache-to: type=gha,mode=max
45 | push: true
46 | tags: |
47 | ghcr.io/${{ github.repository }}:latest
48 | ghcr.io/${{ github.repository }}:${{ github.sha }}
49 | docker.io/iainbullock/tesla_http_proxy:latest
50 | docker.io/iainbullock/tesla_http_proxy:${{ github.ref_name }}
51 |
--------------------------------------------------------------------------------
/nginx_tesla.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | listen [::]:80;
4 | server_name tesla.example.com; # Change to match your own FQDN
5 | return 302 https://$server_name$request_uri;
6 | }
7 |
8 | server {
9 | listen 443 ssl http2;
10 | listen [::]:443 ssl http2;
11 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
12 | server_name tesla.example.com; # Change to match your own FQDN
13 |
14 | ssl_session_timeout 1d;
15 | ssl_session_cache shared:MozSSL:10m;
16 | ssl_session_tickets off;
17 |
18 | # Change this to point to your own ssl certificates. I'm using Cloudflare, but you could use DuckDNS etc
19 | # Make sure your site is working properly using ssl before proceeding with installation of tesla_http_proxy_docker
20 | ssl_certificate /etc/nginx/ssl/cloudflare/cert.pem;
21 | ssl_certificate_key /etc/nginx/ssl/cloudflare/key.pem;
22 |
23 | # dhparams file
24 | #ssl_dhparam /data/dhparams.pem;
25 |
26 | proxy_buffering off;
27 |
28 | # root /usr/share/nginx/tesla_http_proxy;
29 | # index index.html index.htm;
30 |
31 | resolver 127.0.0.11;
32 | set $target __PROXYHOST__;
33 |
34 | # temporary Flask app for initial auth
35 | location / {
36 | proxy_pass http://192.168.0.3:8099; # Change to hostname or IP of your Docker host
37 | }
38 |
39 | # static public key for Tesla
40 | location /.well-known/appspecific/com.tesla.3p.public-key.pem {
41 | root /usr/share/nginx/tesla_http_proxy;
42 | try_files /com.tesla.3p.public-key.pem =404;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | volumes:
4 | tesla_http_proxy:
5 | external: true
6 |
7 | services:
8 | tesla_http_proxy:
9 | container_name: tesla_http_proxy
10 | image: "iainbullock/tesla_http_proxy:latest"
11 |
12 | environment:
13 | - TZ='Europe/London'
14 | - CLIENT_ID='client_id'
15 | - CLIENT_SECRET='client_secret'
16 | - DOMAIN='tesla.example.com' # Public FQDN
17 | - PROXY_HOST='hostname.local' # Local hostname (not IP) of this docker host
18 | - REGION='Europe, Middle East, Africa' # Change to match your region. Other options are 'North America, Asia-Pacific' or 'China'
19 |
20 | stdin_open: true
21 | tty: true
22 |
23 | entrypoint: "/app/run.sh"
24 | working_dir: /app
25 |
26 | volumes:
27 | - tesla_http_proxy:/data
28 | # Webserver root for the $DOMAIN virtual server. Change the source path according to your webserver setup.
29 | # Path must exist or this container won't start. Do not change the target path
30 | - type: bind
31 | source: /var/lib/docker/volumes/nginx/_data/tesla_http_proxy
32 | target: /share/nginx
33 | # Path to tesla_http_proxy directory inside /config on Home Assistant instance. Change the source path according to your HA setup.
34 | # Path must exist or this container won't start. Do not change the target path
35 | - type: bind
36 | source: /var/lib/docker/volumes/home-assistant/_data/tesla_http_proxy
37 | target: /share/home-assistant
38 |
39 | network_mode: bridge
40 | ports:
41 | - 4430:443
42 | - 8099:8099
43 |
44 | restart: no
45 | #restart: unless-stopped
46 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
23 |
24 |
25 |
26 | Tesla HTTP Proxy setup
27 |
28 |
32 |
33 |
37 |
41 |
45 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/ash
2 | set -e
3 |
4 | # read options
5 | cp -n /app/config.sh /data
6 | . /data/config.sh
7 |
8 | # Exit if options not setup
9 | if [ $OPTIONS_COMPLETE != 1 ]; then
10 | echo "Configuration options not set in /data/config.sh, exiting"
11 | echo "Change OPTIONS_COMPLETE=0 to OPTIONS_COMPLETE=1 in /data/config.sh when the configuration parameters have been set"
12 | exit 0
13 | fi
14 |
15 | echo "Configuration Options are:"
16 | echo CLIENT_ID=$CLIENT_ID
17 | echo "CLIENT_SECRET=Not Shown"
18 | echo DOMAIN=$DOMAIN
19 | echo PROXY_HOST=$PROXY_HOST
20 | echo REGION=$REGION
21 |
22 | generate_ssl_certs() {
23 | # generate self signed SSL certificate
24 | echo "Generating self-signed SSL certificate"
25 | openssl req -x509 -nodes -newkey ec \
26 | -pkeyopt ec_paramgen_curve:secp521r1 \
27 | -pkeyopt ec_param_enc:named_curve \
28 | -subj "/CN=${PROXY_HOST}" \
29 | -keyout /data/key.pem -out /data/cert.pem -sha256 -days 3650 \
30 | -addext "extendedKeyUsage = serverAuth" \
31 | -addext "keyUsage = digitalSignature, keyCertSign, keyAgreement"
32 | mkdir -p /share/home-assistant
33 | cp /data/cert.pem /share/home-assistant/selfsigned.pem
34 | }
35 |
36 | generate_tesla_keypair() {
37 | # Generate keypair
38 | echo "Generating keypair"
39 | mkdir -p /share/nginx
40 | tesla-keygen -f -keyring-type pass -key-name myself create >/share/nginx/com.tesla.3p.public-key.pem
41 | cat /share/nginx/com.tesla.3p.public-key.pem
42 | }
43 |
44 | # run on first launch only
45 | if ! pass >/dev/null 2>&1; then
46 | echo "Setting up for first launch"
47 | echo "Setting up GnuPG and password-store"
48 | mkdir -m 700 -p /data/gnugpg
49 | gpg --batch --passphrase '' --quick-gen-key myself default default
50 | gpg --list-keys
51 | pass init myself
52 | generate_tesla_keypair
53 |
54 | # verify certificate exists
55 | elif [ ! -f /share/nginx/com.tesla.3p.public-key.pem ]; then
56 | echo "Public key com.tesla.3p.public-key.pem missing from /share"
57 | generate_tesla_keypair
58 | fi
59 |
60 | if [ -f /share/home-assistant/selfsigned.pem ] && [ -f /data/key.pem ]; then
61 | certPubKey="$(openssl x509 -noout -pubkey -in /share/home-assistant/selfsigned.pem)"
62 | keyPubKey="$(openssl pkey -pubout -in /data/key.pem)"
63 | if [ "${certPubKey}" == "${keyPubKey}" ]; then
64 | echo "Found existing keypair"
65 | else
66 | echo "Existing certificate is invalid"
67 | generate_ssl_certs
68 | fi
69 | else
70 | echo "SSL certificate does not exist"
71 | generate_ssl_certs
72 | fi
73 |
74 | if ! [ -f /data/access_token ]; then
75 | echo "Starting temporary Python app for authentication flow. Delete /data/access_token to force regeneration in the future"
76 | python3 /app/run.py --client-id "$CLIENT_ID" --client-secret "$CLIENT_SECRET" --domain "$DOMAIN" --region "$REGION" --proxy-host "$PROXY_HOST"
77 | fi
78 |
79 | echo "Starting Tesla HTTP Proxy"
80 | tesla-http-proxy -keyring-debug -keyring-type pass -key-name myself -cert /data/cert.pem -tls-key /data/key.pem -port 443 -host 0.0.0.0 -verbose
81 |
--------------------------------------------------------------------------------
/tesla_http_proxy/CLOUDFLARE.md:
--------------------------------------------------------------------------------
1 | # Tesla HTTP Proxy Cloudflare Tunnel Config
2 | A short guide for hosting the Tesla HTTP Proxy through a Cloudflare tunnel.
3 | ## Assumptions
4 | This guide assumes the following:
5 | * You have a working Cloudflare tunnel on your Home Assistant instance
6 | * You are using the [Cloudflared add-on](https://github.com/brenner-tobias/addon-cloudflared) for Home Assistant
7 | * You have configured your developer account on [developer.tesla.com](https://developer.tesla.com) and have your Client ID / Secret Key
8 | * You **have not installed the Nginx add-on** (uninstall it if you have)
9 | ## Configure Cloudflare Zero Trust
10 | * In the Zero Trust control panel, select your tunnel and add a new public hostname
11 | * The subdomain should match the one used on the Tesla developer page (Example: tsla.someplace.com)
12 | * Type: HTTPS
13 | * URL: IP:Port used for Nginx (Example: 192.168.1.2:10443)
14 | * Click the "Additional application settings" link below the hostname config
15 | * TLS > Origin Server Name
16 | * Enter your domain name _without the subdomain_ (Example: someplace.com)
17 | * TLS > No TLS Verify
18 | * Enabled (check the box)
19 | * Click "Save hostname"
20 | ## Configure the Cloudflared Home Assistant add-on
21 | * Configure the following in the "Additional Hosts" section of the add-on:
22 | ```
23 | - hostname: tsla.someplace.com
24 | service: https://192.168.1.2:10443
25 | originRequest:
26 | noTLSVerify: true
27 | originServerName: someplace.com
28 | ```
29 | ## Install and configure the Nginx Home Assistant add-on
30 | * Install the Nginx add-on from the Home Assistant add-on library
31 | * Set your domain (Example: someplace.com)
32 | * Select the "Cloudflare" option so Nginx adds Cloudflare's IPs to its config
33 | * Set your port to the one you configured in the Cloudflare Zero Trust control panel
34 | * Save and start Nginx
35 |
36 | ## Install and configure the Tesla HTTP Proxy add-on
37 | * Install Tesla HTTP Proxy from the Home Assistant add-on library
38 | * Configure your Client ID, Client Secret, and FQDN (Example: tsla.someplace.com)
39 | * Save and start the add-on
40 |
41 | ## Reconfigure the Nginx add-on
42 | * In the "Customize" section, configure the following:
43 | ```
44 | active: true
45 | default: nginx_proxy_default*.conf
46 | servers: nginx_proxy/*.conf
47 | ```
48 | * Save and restart the add-on
49 |
50 | ## Finishing Up
51 | Watch the Tesla HTTP Proxy logs. If everything was configured correctly, you should see "Starting Tesla HTTP Proxy" at the bottom of your logs.
52 | ```
53 | [18:05:36] webui:INFO: Starting Flask server for Web UI...
54 | [18:05:36] werkzeug:INFO: WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
55 | * Running on all addresses (0.0.0.0)
56 | * Running on http://127.0.0.1:8099
57 | * Running on http://172.30.33.12:8099
58 | [18:05:36] werkzeug:INFO: Press CTRL+C to quit
59 | [18:05:37] INFO: Found existing keypair
60 | [18:05:37] INFO: Testing public key...
61 | HTTP/2 200
62 | .
63 | .
64 | .
65 | -----BEGIN PUBLIC KEY-----
66 | .
67 | .
68 | -----END PUBLIC KEY-----
69 | [18:05:37] INFO: Running auth.py
70 | [18:05:38] auth:INFO: Generating Partner Authentication Token
71 | [18:05:38] auth:INFO: Registering Tesla account...
72 | [18:05:39] INFO: Starting Tesla HTTP Proxy
73 | ```
74 | Proceed with the rest of the setup / configuration as per the standard configuration instructions.
75 |
76 | ## Debugging
77 | If things don't seem to be working as expected, be sure to check the Cloudflared, Nginx, and Tesla HTTP Proxy logs for clues.
--------------------------------------------------------------------------------
/tesla_http_proxy/DOCS.md:
--------------------------------------------------------------------------------
1 | # Home Assistant Add-on: Tesla HTTP Proxy
2 |
3 | Needs updating for the docker version
4 |
5 | ## Prerequisites
6 |
7 | You must be running the [Nginx SSL proxy add-on](https://github.com/home-assistant/addons/tree/master/nginx_proxy) because this add-on will add some custom config to that one.
8 |
9 | Your Home Assistant must have a publicly resolvable domain name with a valid SSL certificate and it must be on standard port 443.
10 |
11 | You must create an additional DNS record that resolves to the same IP as Home Assistant. For example, if Home Assistant is `home.example.com` then create `tesla.example.com` as an alias pointing to the same place.
12 |
13 | ## How to use
14 |
15 | Request application access at [developer.tesla.com](https://developer.tesla.com). My request was approved immediately but YMMV. This is currently free but it's possible they will monetize it in the future. You will need to provide the following information:
16 |
17 | - Name of your legal entity (first and last name is fine)
18 | - App Name, Description, Purpose (can be anything)
19 | - **Allowed Origin**: matching the FQDN of your Home Assistant server. Must be lowercase, e.g. `https://tesla.example.com`
20 | - **Redirect URI**: Append `/callback` to the FQDN, e.g. `https://tesla.example.com/callback`
21 | - **Scopes**: `vehicle_device_data`, `vehicle_cmds`, `vehicle_charging_cmds`
22 |
23 | Tesla will provide a Client ID and Client Secret. Enter these in add-on configuration.
24 |
25 | Customize the Nginx add-on configuration like this and then restart it
26 | ```
27 | active: true
28 | default: nginx_proxy_default*.conf
29 | servers: nginx_proxy/*.conf
30 | ```
31 |
32 | Start this add-on and wait for it to initialize. It will fail with an error because Nginx is not configured correctly.
33 |
34 | Restart this add-on and this time it should succeed.
35 |
36 | Open this add-on Web UI in the iOS Home Assistant app and click **Generate OAuth Token**. This will launch a web browser where you authenticate with Tesla. The API refresh token is printed to the log. Write this down as it will not be shown again after you restart the add-on.
37 |
38 | Return to the add-on Web UI and click **Enroll public key in your vehicle**. This will launch the Tesla app where it prompts for approval.
39 |
40 | After that is complete, click **Shutdown Flask Server**. Now the Tesla HTTPS proxy will start, and the `Regenerate auth` setting will be automatically disabled.
41 |
42 | Configure the [Tesla integration](https://github.com/alandtse/tesla) to use this proxy.
43 |
44 | ## Troubleshooting
45 |
46 | Check the add-on logs to see what's happening.
47 |
48 | From the add-on Web UI there is a link to test your public key HTTPS endpoint. It should return the contents of your public key, similar to this:
49 |
50 | ```
51 | -----BEGIN PUBLIC KEY-----
52 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEcCTVZI7gyAGiVq2jdBjg4MOiXxsh
53 | nxjvrm2M6uKfDEYS52ITVVbzqGMzzbKCO/tuu78432jU6Z96BNR8NSoRXg==
54 | -----END PUBLIC KEY-----
55 | ```
56 |
57 | You should have a config file at `/share/nginx_proxy/nginx_tesla.conf` that does two things. You may need to modify this file depending on your SSL config.
58 |
59 | - Host the static public key file
60 | - Proxy port 8099 to the built in Flask app
61 |
62 | This was tested with a 2021 Model 3 in the United States. Other regions may require different endpoints.
63 |
64 | If you get `login_required` error when trying to send API commands, it's likely because you tried to reuse the refresh token more than once. https://github.com/teslamotors/vehicle-command/issues/160
65 |
66 | To test the proxy, you can make requests from inside the Home Assistant container like this:
67 |
68 | ```
69 | curl --cacert /share/tesla/selfsigned.pem \
70 | --header "Authorization: Bearer $TESLA_AUTH_TOKEN" \
71 | "https://addon-tesla-http-proxy/api/1/vehicles"
72 | ```
73 |
--------------------------------------------------------------------------------
/tesla_http_proxy/app/run.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import uuid
4 | import logging
5 | import argparse
6 | import requests
7 | from flask import Flask, request, render_template, cli, redirect
8 | from werkzeug.exceptions import HTTPException
9 |
10 | logging.basicConfig(
11 | format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s",
12 | level=logging.INFO,
13 | datefmt="%H:%M:%S",
14 | )
15 | logger = logging.getLogger("main")
16 |
17 | app = Flask(__name__)
18 |
19 | SCOPES = "openid offline_access vehicle_device_data vehicle_cmds vehicle_charging_cmds"
20 | AUDIENCES = {
21 | "North America, Asia-Pacific": "https://fleet-api.prd.na.vn.cloud.tesla.com",
22 | "Europe, Middle East, Africa": "https://fleet-api.prd.eu.vn.cloud.tesla.com",
23 | "China": "https://fleet-api.prd.cn.vn.cloud.tesla.cn",
24 | }
25 | BLUE = "\u001b[34m"
26 | RESET = "\x1b[0m"
27 |
28 | parser = argparse.ArgumentParser()
29 |
30 | parser.add_argument(
31 | "--client-id",
32 | help="Client ID. Required if not provided in environment variable CLIENT_ID",
33 | default=os.environ.get("CLIENT_ID"),
34 | )
35 | parser.add_argument(
36 | "--client-secret",
37 | help="Client secret. Required if not provided in environment variable CLIENT_SECRET",
38 | default=os.environ.get("CLIENT_SECRET"),
39 | )
40 | parser.add_argument(
41 | "--domain",
42 | help="Domain. Required if not provided in environment variable DOMAIN",
43 | default=os.environ.get("DOMAIN"),
44 | )
45 | parser.add_argument(
46 | "--region",
47 | choices=AUDIENCES.keys(),
48 | help="Region. Required if not provided in environment variable REGION",
49 | default=os.environ.get("REGION"),
50 | )
51 | parser.add_argument(
52 | "--proxy-host",
53 | help="Proxy host. Required if not provided in environment variable PROXY_HOST",
54 | default=os.environ.get("PROXY_HOST"),
55 | )
56 |
57 | args = parser.parse_args()
58 |
59 | if (
60 | not args.client_id
61 | or not args.client_secret
62 | or not args.domain
63 | or not args.region
64 | or not args.proxy_host
65 | ):
66 | parser.print_help()
67 | sys.exit(1)
68 |
69 |
70 | @app.errorhandler(Exception)
71 | def handle_exception(e):
72 | """Exception handler for HTTP requests"""
73 | logger.error(e)
74 | # pass through HTTP errors
75 | if isinstance(e, HTTPException):
76 | return e
77 |
78 | # now you're handling non-HTTP exceptions only
79 | return "Unknown Error", 500
80 |
81 |
82 | @app.route("/")
83 | def index():
84 | """Web UI"""
85 | return render_template(
86 | "index.html",
87 | domain=args.domain,
88 | client_id=args.client_id,
89 | scopes=SCOPES,
90 | randomstate=uuid.uuid4().hex,
91 | randomnonce=uuid.uuid4().hex,
92 | )
93 |
94 |
95 | @app.route("/callback")
96 | def callback():
97 | """Handle POST callback from Tesla server to complete OAuth"""
98 |
99 | logger.info("callback args: %s", request.args)
100 | # sometimes I don't get a valid code, not sure why
101 | try:
102 | code = request.args["code"]
103 | except KeyError:
104 | logger.error("args: %s", request.args)
105 | return "Invalid code!", 400
106 |
107 | # Exchange code for refresh_token
108 | req = requests.post(
109 | "https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token",
110 | headers={"Content-Type": "application/x-www-form-urlencoded"},
111 | data={
112 | "grant_type": "authorization_code",
113 | "client_id": args.client_id,
114 | "client_secret": args.client_secret,
115 | "code": code,
116 | "audience": AUDIENCES[args.region],
117 | "redirect_uri": f"https://{args.domain}/callback",
118 | },
119 | timeout=30,
120 | )
121 |
122 | output = (
123 | "Info to enter into Tesla Custom component:\n"
124 | f"Refresh token : {BLUE}{req.json()['refresh_token']}{RESET}\n"
125 | f"Proxy URL : {BLUE}https://{args.proxy_host}:4430{RESET}\n"
126 | f"SSL certificate: {BLUE}/share/home-assistant/selfsigned.pem{RESET}\n"
127 | f"Client ID : {BLUE}{args.client_id}{RESET}\n"
128 | )
129 |
130 | logger.info(output)
131 |
132 | req.raise_for_status()
133 | with open("/data/refresh_token", "w", encoding="utf-8") as f:
134 | f.write(req.json()["refresh_token"])
135 | with open("/data/access_token", "w", encoding="utf-8") as f:
136 | f.write(req.json()["access_token"])
137 |
138 | return render_template("callback.html")
139 |
140 |
141 | @app.route("/shutdown")
142 | def shutdown():
143 | """Shutdown Flask server so the HTTP proxy can start"""
144 | os._exit(0)
145 |
146 |
147 | @app.route("/register-partner-account")
148 | def register_partner_account():
149 | """Register the partner account with Tesla API to enable API access"""
150 |
151 | logger.info("*** Generating Partner Authentication Token ***")
152 |
153 | req = requests.post(
154 | "https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token",
155 | headers={"Content-Type": "application/x-www-form-urlencoded"},
156 | data={
157 | "grant_type": "client_credentials",
158 | "client_id": args.client_id,
159 | "client_secret": args.client_secret,
160 | "scope": SCOPES,
161 | "audience": AUDIENCES[args.region],
162 | },
163 | timeout=30,
164 | )
165 | if req.status_code >= 400:
166 | logger.error("HTTP %s: %s", req.status_code, req.reason)
167 | logger.error(req.text)
168 | return redirect(f"/?error={req.status_code}", code=302)
169 |
170 | logger.info(req.text)
171 | tesla_api_token = req.json()["access_token"]
172 |
173 | # register Tesla account to enable API access
174 | logger.info("*** Registering Tesla account ***")
175 | req = requests.post(
176 | f"{AUDIENCES[args.region]}/api/1/partner_accounts",
177 | headers={
178 | "Authorization": "Bearer " + tesla_api_token,
179 | "Content-Type": "application/json",
180 | },
181 | data='{"domain": "%s"}' % args.domain,
182 | timeout=30,
183 | )
184 | if req.status_code >= 400:
185 | logger.error("Error %s: %s", req.status_code, req.reason)
186 | logger.error(req.text)
187 | return redirect(f"/?error={req.status_code}", code=302)
188 | logger.info(req.text)
189 |
190 | return redirect("/?success=1", code=302)
191 |
192 |
193 | if __name__ == "__main__":
194 | logger.info("*** Starting Flask server... ***")
195 | cli.show_server_banner = lambda *_: None
196 | app.run(port=8099, debug=False, host="0.0.0.0")
197 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tesla HTTP Proxy Docker
2 |
3 | Tested and working as expected with Home Assistant custom integration https://github.com/alandtse/tesla
4 |
5 | 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.
6 |
7 | This version provides a standalone docker version instead of a Home Assistant Add-on. This means it can work with versions of Home Assistant which don't allow Add-Ons (e.g. docker version).
8 |
9 | This docker runs the official Tesla HTTP Proxy to allow Fleet API requests on modern vehicles. Please do not bother Tesla for support on this.
10 |
11 |
12 |
13 | ## About
14 | Runs a temporary Flask web server to handle initial Tesla authorization flow and store the refresh token. Once that is complete, it quits Flask and runs Tesla's HTTP Proxy code in Go.
15 |
16 | Setting this up is fairly complex. Please read [DOCS.md](./tesla_http_proxy/DOCS.md) for details (TODO), or follow the high level summary below:
17 |
18 | ## Installation and set up
19 |
20 | Many thanks to [@tux43](https://github.com/tux43) for creating this blog, which describes his set up in detail: https://www.smartmotion.life/2024/04/23/tesla-custom-integration-with-home-assistant-on-docker
21 |
22 | Also many thanks to [@juchong](https://github.com/juchong) for writing a Cloudflare configuration / setup guide: [CLOUDFLARE.md](./tesla_http_proxy/CLOUDFLARE.md)
23 |
24 | - Setup your webserver so it can receive ssl connections to your FQDN from the internet. This FQDN should be different to that used to access your instance of Home Assistant. I have provided my Nginx configuration file (nginx_tesla.conf). The default config for this project assumes you are running Nginx in its own docker container, and the webserver document root for the FQDN is at /var/lib/docker/volumes/nginx/_data/tesla_http_proxy on the docker host. This can be changed in docker-compose.yml
25 |
26 | - Create a directory tesla_http_proxy in the /config directory of your Home Assistant (HA) instance. The default config for this project assumes you are running HA in its owner docker container and /config/tesla_http_proxy is at /var/lib/docker/volumes/home-assistant/_data/tesla_http_proxy on the docker host. This can be changed in docker-compose.yml
27 |
28 | - Build the docker image using the Dockerfile. Alternatively you can get the image directly from Dockerhub https://hub.docker.com/r/iainbullock/tesla_http_proxy
29 |
30 | - Make any required changes required to suit your setup in docker-compose.yml, and deploy the stack. On the first run of the container various files will be initialised and the container will exit
31 |
32 | - Enter your configuration parameters in /data/config.sh (/data is mounted as a volume on the docker host). This will override those specified in docker-compose.yml. Note that PROXY_HOST must not be an IP address; it must be a hostname which resolves to the IP address of your docker host in both HA and proxy containers. Change OPTIONS_COMPLETE=0 to OPTIONS_COMPLETE=1 in /data/config.sh when the configuration parameters have been entered
33 |
34 | - 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
35 |
36 | - 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
37 |
38 | - 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
39 |
40 | - 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
41 |
42 | - 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:
43 |
44 | [16:14:02] main:INFO: *** Generating Partner Authentication Token ***
45 | [16:14:03] main:INFO: {"access_token":"LongString","expires_in":28800,"token_type":"Bearer"}
46 | [16:14:03] main:INFO: *** Registering Tesla account ***
47 | [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"}}
48 | [16:14:05] werkzeug:INFO: 192.168.1.5 - - [07/Apr/2024 16:14:05] "GET /register-partner-account HTTP/1.0" 302 -
49 | [16:14:05] werkzeug:INFO: 192.168.1.5 - - [07/Apr/2024 16:14:05] "GET /?success=1 HTTP/1.0" 200 -
50 |
51 | - 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
52 |
53 | - 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
54 |
55 | - Optionally test using curl. See [DOCS.md](./tesla_http_proxy/DOCS.md) for details (TODO)
56 |
57 | - Once you are happy it is working, change restart: no to restart: unless-stopped in your docker-compose.yml, and restart the stack
58 |
59 | ## Setup Home Assistant Custom Integration ##
60 |
61 | - Install using HACS. Start the config flow.
62 |
63 | - On the 'Tesla - Configuration dialog, click 'Use Fleet API Proxy'
64 |
65 | - On the 'Tesla - Configuration' dialog, enter the email address associated with your Tesla Developer account. Obtain the refresh token from /data/refresh_token and enter into the 'Refresh Token' field. Note refresh tokens only work once and only last a short time before they expire. See the [DOCS.md](./tesla_http_proxy/DOCS.md) for details of how to get a new one (TODO). Enter the hostname and port for your proxy in URL format (in my case this is https://macmini.home:4430. It cannot be an IP address). Enter /config/tesla_http_proxy/selfsigned.pem into the 'Proxy SSL certificate' field.
66 |
67 | - If the initialisation is successful, you will be presented with a 'Success!' dialog, with your name of your vehicle shown. Click the 'Finish' button and the entities for your vehicle will have been created. If the integration fails to setup, the most likely issues are: your refresh token has expired; or the SSL certificate that HA uses to connect to the proxy is invalid (e.g. you used an IP rather than hostname, the hostname doesn't resolve to the IP address of your docker host in both HA and proxy containers)
68 |
69 | - Test the integration, in particular by issuing a command e.g. to open the boot. If that fails, most likely culprit is that your webserver is not serving your vehicle's public key (com.tesla.3p.public-key.pem) to Tesla which is required for commands to work
70 |
71 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------