Skip to content

Commit

Permalink
fix(api): fixes for tesla 20.49 API changes
Browse files Browse the repository at this point in the history
With the 20.49 firmware update by Tesla, the endpoints that previously
were open are no longer available without authentication. Unfortuantely,
the mechanism used for authentication is not HTTP basic, rather it's
cookie based. This change brings in an additional container that I
created called cookieproxy, that can be used to proxy the cookie based
requests through to the Powerwall gateway.

In contrast to previous versions, this requires no compilation of
containers on the local machine and no modifications to the more common
containers of influxdb, grafana, and telegraf. There is a small
customization that is required to store the password of your Powerwall
in the `.env.cookieproxy` file, but otherwise it should be plug and play
with the previous versions of mihailescu2m/powerwall_monitor.

See mihailescu2m#14

DCO 1.1 Signed-off-by: Patrick Wagstrom <[email protected]>
  • Loading branch information
pridkett committed Apr 11, 2021
1 parent baa44cc commit a1765c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions powerwall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ services:
published: 8086
mode: host

cookieproxy:
image: pridkett/cookieproxy:0.1.0
container_name: cookieproxy
hostname: cookieproxy
restart: always
command: ["/bin/sh", "-c", '/go/bin/cookieproxy -request "{\"url\": \"https://powerwall/api/login/Basic\", \"headers\": {\"Content-Type\": \"application/json\"}, \"body\": \"{\\\"username\\\":\\\"customer\\\",\\\"password\\\":\\\"$$POWERWALL_PASSWORD\\\", \\\"force_sm_off\\\":false}\", \"method\": \"POST\"}"']
extra_hosts:
- "powerwall: 192.168.91.1"
env_file:
- .env.cookieproxy

telegraf:
image: telegraf:1.12
container_name: telegraf
Expand All @@ -29,10 +40,9 @@ services:
source: ./telegraf.conf
target: /etc/telegraf/telegraf.conf
read_only: true
extra_hosts:
- "powerwall: 192.168.91.1"
depends_on:
- influxdb
- cookieproxy

grafana:
image: grafana/grafana:6.5.1-ubuntu
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Monitoring the Tesla Powerwall with the TICK framework

## Installation
* edit `powerwall.yml` and replace `192.168.91.1` with your powerwall IP
* create a file called `.env.cookieproxy` to define the `POWERWALL_PASSWORD` which
is used for authentication. This should be a single line that looks like this:
```
POWERWALL_PASSWORD=YourPowerwallPassword
```
* start the docker containers: `docker-compose -f powerwall.yml up -d`
* connect to the Influx database shell: `docker exec -it influxdb influx`
* at the database prompt, enter the following commands:
Expand Down
4 changes: 2 additions & 2 deletions telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@

[[inputs.http]]
urls = [
"https://powerwall/api/meters/aggregates",
"https://powerwall/api/system_status/soe"
"http://cookieproxy:8675/p/?target=https://powerwall/api/meters/aggregates",
"http://cookieproxy:8675/p/?target=https://powerwall/api/system_status/soe"
]
method = "GET"
insecure_skip_verify = true
Expand Down

0 comments on commit a1765c0

Please sign in to comment.