rhodesman / teslaPowerDash

GNU General Public License v3.0
85 stars 11 forks source link

Changes in Tesla API calls #19

Closed rhodesman closed 3 years ago

rhodesman commented 3 years ago

As of earlier this week it looks like Tesla has changed the way to access their API. It will require me to rebuild the entire middleware software to accommodate the new protocols they now have in place.

Just know I am aware of the issue and am trying to build a solution that addresses it and the other issues with the middleware that were brought to my attention.

caseybecking commented 3 years ago

Just for clarification - this issue will cause the data to not populate into the database correct?

Here-Be-Dragons commented 3 years ago

I have my dashboard functional again, using Vince Loschiavo's script with a slight modification at the bottom. Note that in order for this to work, you have to add to the telegraf config.

Vince's original script: https://raw.githubusercontent.com/vloschiavo/powerwall2/master/samples/powerwallstats.sh My modification, adding a few lines to the bottom: https://gist.github.com/Here-Be-Dragons/fb51de47c84a6ad0426175ab08295235

The new telegraf snippet (I only had to add the headers line:)

 [[inputs.http]]
   urls = [
     "https://192.168.1.140/api/meters/aggregates",
     "https://192.168.1.140/api/system_status/soe",
     "https://192.168.1.140/api/meters/solar",
     "https://192.168.1.140/api/sitemaster",
     "https://192.168.1.140/api/system_status/grid_status",
     "https://192.168.1.140/api/status"
   ]
    method = "GET"
    insecure_skip_verify = true
    timeout = "5s"
    data_format = "json"
    headers = {"Cookie" = "AuthCookie=abcd; UserRecord=efgh"}

Once that file exists, toss my version of Vince's script into /etc/cron.hourly/ and chmod +x it so it can be executed, and then your (Linux) OS will check the cookie hourly, replacing as needed.

steviehs commented 3 years ago

perfect! thanks a lot. Now, who brings me back my 15 lost hours of data? :-)

rhodesman commented 3 years ago

@Here-Be-Dragons Awesome work!!!! Thank you for figuring this out.

Nakatomi2010 commented 3 years ago

Has this change been committed to the repo?

I've tried spinning up a new instance, or just updating the existing one and it still isn't picking up new data.

rhodesman commented 3 years ago

@Nakatomi2010 I have not updated the repo yet but it's coming soon. Been working on adding this update to the nodejs middleware to include these new steps but this isn't my full-time job so I can only work on this in my free time.

rhodesman commented 3 years ago

I have edited the powerwallstats.sh file to work on MacOS (10.12+) and telegraf installed via Homebrew: powerwallstats.sh

Jernau commented 3 years ago

I 100% understand you do this great work for no reward and that other things have to come first but do you have any idea when you might be able to update it to work with Tesla's new nonsense? I only ask as before finding this thread I was looking at alternatives and none seem to work as well as this (if at all). If I know how long you need I can decide whether or not to spend time on temporary measures. Thanks.

steviehs commented 3 years ago

@Jernau just follow @Here-Be-Dragons recipe and use the rest from this repo, it is quite easy.

Jernau commented 3 years ago

I've tried but can't get it to work for some reason. I suspect it might be the password. I'm using the one it gives you via the powerwall main local web page after flicking the switch on/off. Is this the right one?

steviehs commented 3 years ago

"Login to the Powerwall UI and Set this password - follow the on-screen instructions" Dunno if the Powerwall reacts different on the passwort after reset or one you set on your self. But yes, this is the UI password. You can start this script with bash -x to understand if there is happening anything strange...

Jernau commented 3 years ago

bash -x confirms it's "bad credentials" but I've checked the password and it seems right. I can only think there's more than one password or maybe UK models are doing something differently. Very frustrating :(.

rhodesman commented 3 years ago

@Jernau Can you login to the power walls directly with the credentials you are using in the Dashboard API? If they work there and not in the API then I would guess something is calling to the wrong end link or the script is not setup correctly for your system. If they don't work, then I would call into Tesla Support and see if they can either reset your power wall password or help you figure out what the correct password is.

rhodesman commented 3 years ago

closing this issue as a new update from Tesla has depreciated this issue