jasonacox / Powerwall-Dashboard

Grafana Monitoring Dashboard for Tesla Solar and Powerwall Systems
MIT License
273 stars 57 forks source link

Powerwall 3 Support #387

Open jesaf00 opened 8 months ago

jesaf00 commented 8 months ago

Problem Powerwall 3 not compatible with Powerwall-Dashboard

Enhancement I would like to help make it work if I can

Additional context I have 3x Powerwall 3s just installed with a tesla backup switch and would like to be able to use this tool.

jesaf00 commented 7 months ago

Here are my results...

Tesla Account Setup
-------------------
Email address: myemail@gmail.com

Config saved to '/var/lib/tesla-history/tesla-history.conf'

----------------------------------------
Tesla account: myemail@gmail.com
----------------------------------------
Open the below address in your browser to login.

https://auth.tesla.com/oauth2/v3/authorize?response_type=code&client_id=ownerapi&redirect_uri=https%3A%2F%2Fauth.tesla.com%2Fvoid%2Fcallback&scope=openid+email+offline_access&state=d2mvl2SQYIBBdKerwpkUfdfnAzwGqT&code_challenge=lpsbKVScxeDMCMi3d4DKMQXQgoJUGiFuBH1ISmFU7gw&code_challenge_method=S256&login_hint=myemail%40gmail.com

After login, paste the URL of the 'Page Not Found' webpage below.

Enter URL after login: https://auth.tesla.com/void/callback?code=NA_8091ab256d05f3d2f96b8e970f3ee04be42b6dbc32b5038955172702ab91&state=d2mvl2SQYIBBdKerwpkUfdfnAzwGqT&issuer=https%3A%2F%2Fauth.tesla.com%2Foauth2%2Fv3
----------------------------------------
ERROR: Failed to retrieve PRODUCT_LIST - RetryError(MaxRetryError("HTTPSConnectionPool(host='owner-api.teslamotors.com', port=443): Max retries exceeded with url: /api/1/products (Caused by ResponseError('too many 500 error responses'))"))
Restarting tesla-history...
tesla-history
------------------[ Final Setup Instructions ]-----------------
jasonacox commented 7 months ago

Thanks @jesaf00 ! Are you using the same credentials you use for the Tesla App?

@mcbirse Have you seen this before?

jesaf00 commented 7 months ago

Well, IDK what happened. I deleted the container, reran the setup and it succeeded without asking for my PW. and here we are....

image
jasonacox commented 7 months ago

Wow! 🚀 Nice job @jesaf00 - First to have a Powerwall 3 Dashboard up and running. ❤️

Did you also run the "Load History" steps? I assume that's how you have 24hr of data.

You can delete the "Power Flow" panel. It is based on pypowerwall proxying the Powerwall2/+ portal UI. The dashboard-no-animation.json dashboard replaces that spot with a Powerwall charge bar graph and piechart.

image
jesaf00 commented 7 months ago

Yes sir, I did! Thanks for the suggestion about the no animation dashboard. With this working what's next? Need to wait for some API info?

jasonacox commented 7 months ago

Thanks @jesaf00 ! - Can you share another screenshot of your dashboard with the no-animation version?

As to "what's next", I'm researching the Tesla Pros API. I have a first pass at the protobuf schema and if you are interested in testing, I have uploaded them here: https://github.com/jasonacox/pypowerwall/tree/main/tools/tedapi#tools

The test.py script will prompt you for your Powerwall Gateway password (the one on the QR sticker) and will attempt to fetch the DIN (device ID number), current Configuration (warning: contains confidential user and password data), and the current status (not yet working 100%). It will be interesting to see if the Powerwall 3 responds to any of these.

mcbirse commented 7 months ago

@jesaf00 - this is brilliant, thanks for trying it! Glad to see PW3 owners at least have this option for now.

ERROR: Failed to retrieve PRODUCT_LIST - RetryError(MaxRetryError("HTTPSConnectionPool(host='owner-api.teslamotors.com', port=443): Max retries exceeded with url: /api/1/products (Caused by ResponseError('too many 500 error responses'))"))

I suspect this was just a transient connection error to the Tesla host 'owner-api.teslamotors.com' for some reason... maybe the site went down or Internet dropped out briefly, and it happened to occur just after (successful) login when the script attempts to get the site details.

Well, IDK what happened. I deleted the container, reran the setup and it succeeded without asking for my PW.

Yep, login was actually successful and the .conf and .auth files were saved. You would have just been able to re-run setup without removing the container and it would be okay... or even just run docker restart tesla-history. You can always run docker logs tesla-history to confirm the service is operating correctly as well. If it cannot login or get site details, there will be an error and the script will halt, and will require resolving by a restart or re-authenticating.

If this works, we should update the script and README to include language that this supports Powerwall 3 (Tesla Cloud version).

@jasonacox - I agree, it makes sense that we now update the setup script and README to advise PW3 owners to use the "solar-only" option. We could even add a 3rd config profile option depending on what is clearer?

jasonacox commented 7 months ago

@mcbirse - Good idea. But I'm also wondering if we just keep it limited to the two profiles for now while we figure out the final outcome. I'm getting some indication that Tesla won't be interested in providing local API access and pushing for everyone to move the Tesla App as the only location for this data. That could even impact us, as existing PW 2/+ owners (e.g. a firmware that removes the local portal and APIs). I hope that doesn't happen, but it is worth exploring how we would support that transition and make it easy to switch. At a minimum, the profile would allow everyone to continue to get basic information into the Dashboard.

Perhaps we just reword the setup.py profile selection a bit? We may also want to have the script look for compose.env, and if found, prompt the user if they want to change the configuration profile.

Select configuration profile:

  1 - Local Access (Powerwall 1, 2, or + using extended data from Tesla Gateway on LAN) - Default
  2 - Tesla Cloud  (Solar-only, Powerwall 1, 2, +, or 3 using data from Tesla Cloud)

If the 2nd option is selected (solar-only), the setup instructions will point users to use the solar-only or no-animation dashboards.

Also as a mitigation / feature, it would be interesting to see if we can get more "live" data from the Tesla Cloud similar to how the Tesla App works, to render an animation.

mcbirse commented 7 months ago

@jasonacox - Sounds good and makes sense to me. I have started a new branch v3.0.3 and committed some changes which include update to the profile selection descriptions, and allows changing the profile selection when already configured.

I have only done very minimal testing at this point, so if you see any issues feel free to update.

I also had some updates to the pwstatus and weather-history tools to make them a bit more resilient when errors occur, and have included these changes.

jesaf00 commented 7 months ago

Here is the screenshot you asked for.

image
jasonacox commented 7 months ago

Thank's Jerry! 🙏 Does the "Current State" panel not show anything? We should look into that if so. If you don't mind, I would love to use this as a PW3 example on our homepage (README.md). Could you zoom out (Cmd/Ctrl and – (minus) on Chrome) to screen capture down to the "Monthly Analysis" section? Here is what it looks like on my system:

image

We can also update the no-animation dashboard to include the weather and outage data in the main "Energy Usage" graph. I just added that and made a few more edits. Can you try this one?

dashboard-no-animation.json (Updated)

image
jasonacox commented 7 months ago

I have started a new branch v3.0.3

Thanks @mcbirse ! I'll check it out...

jesaf00 commented 7 months ago

Thank's Jerry! 🙏 Does the "Current State" panel not show anything? We should look into that if so. If you don't mind, I would love to use this as a PW3 example on our homepage (README.md). Could you zoom out (Cmd/Ctrl and – (minus) on Chrome) to screen capture down to the "Monthly Analysis" section? Here is what it looks like on my system:

image

We can also update the no-animation dashboard to include the weather and outage data in the main "Energy Usage" graph. I just added that and made a few more edits. Can you try this one?

dashboard-no-animation.json (Updated)

image

Here is with and without animation dashboards.

Screenshot 2023-11-27 at 7 36 51 AM Screenshot 2023-11-27 at 7 36 40 AM
ivberg commented 5 months ago

Interestingly enough I was able to get Tesla private dashboard to work with PW3. I installed Tesla One app and logged in as Tesla partner with my normal Tesla account. Then I could enter WiFi details and connect to the local device. From there the app showed similar to what Tesla app would show with Solar generated, energy from grid, and PW3 discharge. This is nice since my official Tesla app is STILL not working.

Lmk if I can reverse any API info with this? It might be a bit tough since this app is on iOS and packet sniffing might not be so trivial.

jasonacox commented 5 months ago

Hi @ivberg ! We do have an investigation into the tedapi API (Tesla Pros/One) here: https://github.com/jasonacox/Powerwall-Dashboard/discussions/392

I was able to get Tesla private dashboard to work with PW3

What is that dashboard? Do you mean the Powerwall-Dashboard? I would be interested to see what the scan show. I'm somewhat hopeful that Tesla will bring the basic TEG portal to the PW3 as we have with the PW2/+:

pip install pypowerwall
python3 -m pypowerwall scan

Also @jesaf00 - I can't remember if I followed up with you. The latest release (v4.0.1) should provide you with a working animation dashboard if you upgrade. It would be good to see if it works for you.

jwmoss commented 1 month ago

@jasonacox I got this working with powerwall 3 (this being the dashboard animation) using cloud mode only. image

Output from pypowerwall as well.

image

jasonacox commented 1 month ago

Fantastic @jwmoss !!! Are you able to use the Tesla One (Tesla Pros) app to access your PW3? If so, we just made a discovery that could make it possible to unlock even more data from your PW3.

jwmoss commented 1 month ago

Fantastic @jwmoss !!! Are you able to use the Tesla One (Tesla Pros) app to access your PW3? If so, we just made a discovery that could make it possible to unlock even more data from your PW3.

I read the other thread (and I'm still learning!) but it seems that 192.168.91.1 is the ip address of the Backup Gateway 2 and not the PW3, is that correct? I can connect to the Tesla One app with my PW3, but I'm not sure if that's what you'll suggest :)

jasonacox commented 1 month ago

Hi @jwmoss - For the PW3, since it doesn't connect to your LAN, you would need to figure out a way to bridge your networks (or at least the host that runs the Dashboard). Here is one potential path: https://gist.github.com/jasonacox/91479957d0605248d7eadb919585616c

jwmoss commented 1 month ago

Hi @jwmoss - For the PW3, since it doesn't connect to your LAN, you would need to figure out a way to bridge your networks (or at least the host that runs the Dashboard). Here is one potential path: https://gist.github.com/jasonacox/91479957d0605248d7eadb919585616c

I'm confused, the Powerwall 3 SSID is TeslaPW_XXXXXX while the Backup Gateway (TEG?) is TEG-XXX. Is the static route for the Backup Gateway or the Powerwall 3? I can connect to the Powerwall 3 with the Tesla One app, which is 192.168.91.0/24 from what I can tell.

dvwalker commented 1 month ago

Just installed (2) pw3s and getting same 404 as jesaf00 originally reported. I can successfully log into one of my pw3s via wifi using password under the glass cover . Tried all the various urls but all return 404 not found.

The cloud only solution above really is of no use if/when internet goes down. Just like how the telsa app home site page doesn't work in airplane mode.

jasonacox commented 1 month ago

HI @dvwalker - The only URI that the Powerwall 3 will respond to will be the /tedapi API. The rest will give you an error.

In https://github.com/jasonacox/pypowerwall/issues/97 we have the latest Powerwall-Dashboard (upgrade to version 4.4.2) working with Powerwall 3. It requires that the computer that runs the dashboard has access to the Powerwall 3 gateway (192.168.91.1) via WiFi or a network route. To convert your existing installation, edit the pypowerwall.env file:

#PW_EMAIL=
#PW_PASSWORD=
PW_HOST=192.168.91.1
PW_GW_PWD=GWPASSWD

Where GWPASSWD is the gateway password usually found on the WiFi / QR code you mention. Restart with ./compose-dash.sh up -d

dvwalker commented 1 month ago

Thanks Jason, that worked! Started with fresh install on windows 11 PC so took a bit to get all the per-requisites up and running. Your default power flow dashboard (ie, dashboard.json) appears to be working and showing correct energy flow metrics as compared to my telsa app. Kudos and great work!!

Screenshot 2024-06-12 131911

geptto commented 3 weeks ago

This is great stuff you're doing here @jasonacox! I have a PW3 and it is trowing Arc faults. The Tesla One app currently shows an Arc Lockout fault that doesn't show up in the Grafana dashboard, I'm assuming your plan is to have those in the Alerts session. The string data also shows "no data" although that could be because the inverter is down due to the Arc Lockout. How can I help with adding the fault from the PW3 to the dashboard?

I'm doing my own research and will share what I find, adding this comment in case you already have something that could save me time.

Screenshot 2024-06-21 at 18-22-34 Powerwall - Power Flow - Dashboards - Grafana Screenshot 2024-06-21 at 18-23-05 Powerwall - Power Flow - Dashboards - Grafana Screenshot 2024-06-21 at 18-23-20 Powerwall - Power Flow - Dashboards - Grafana Screenshot 2024-06-21 at 18-23-33 Powerwall - Power Flow - Dashboards - Grafana

jasonacox commented 3 weeks ago

Hi @geptto - Thanks for the screenshots! I would love to see what your system is showing using these URLs - if you can find the alerts for the Arc Fault, etc:

I think the missing bits:

"systemStatus": {
"nominalEnergyRemainingWh": 12526,
"nominalFullPackEnergyWh": 25793
"POD": [
{
"POD_EnergyStatus": {
"POD_nom_energy_remaining": 6404,
"POD_nom_full_pack_energy": 13188,
"isMIA": false
},
geptto commented 3 weeks ago
  • , it would be interesting to see if the /tedapi/status URL above shows somthing like this in the JSON:

Hi @jasonacox !

I can't find the fault in any of those URLs. Payloads are attached, please notice I masked any serial numbers or identifiable data.

alerts.json tedapi_config.json tedapi_status.json vitals.json

About the strings, the data must be there somewhere since it is available in the Tesla One app. I'm working on grabbing the network packets between the app and the PW. Will share if I find something useful.

On PW capacity, systemStatus data is available however all objects within the POD array are representing zeroes.

A few screenshots from the app.

Summary Page
Screenshot_20240621-192703_Tesla One\
Detailed Alert

Screenshot_20240621-192714_Tesla One


Strings Data

Screenshot_20240621-193004_Tesla One
jasonacox commented 3 weeks ago

I can't find the fault in any of those URLs. Payloads are attached, please notice I masked any serial numbers or identifiable data.

Thank you! I'm going to look through this to see if there is anything I'm missing that may be PW3 only related.

About the strings, the data must be there somewhere since it is available in the Tesla One app. I'm working on grabbing the network packets between the app and the PW. Will share if I find something useful.

That would be fantastic! All my work so far is baed on having a PW2 and PW+. I don't have a PW3 to test. I suspect there could be other API endpoints or payloads that get the additional data. Let us know if you find anytthing!