Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Discussion: How to get status information from your Powerwalls

This site may earn commission on affiliate links.
I havent seen anything like that in my model 3 either. its 2.5 years old as well. In any case, I wanted to validate what the "simple math" showed, which si why I wanted to know how to get data out of it. I am an IT person but not a coder.
That is a concerning amount of degradation after only 17 months. I'll share my Powerwall data after collecting over a longer period of time. I've had my Model 3 for about 2 years and it's only recently degraded slightly to about 98%-99% of original capacity.

Screen Shot 2021-05-28 at 8.43.28 AM.png
 
man i tried to get this stuff going in python and ran into the same problem i always do - i can never resolve all the dependencies properly because package names conflict and newer versions of packages seem to break the APIs willy-nilly.

does anyone have a venv config that satisfies all the dependencies in the code above?
 
i would be able to do same / run pw's to zero with car see in app energy from pv to fill to 100% ... how close was this method to what api reported for you ?
(sorry if i missed that in your posts) would be nice if and when time comes to inquire with tesla to see how close their response is to my "run down" estimate

I missed this question. I seem to remember it was very close, if I remember it was at least as close as a 10th of a kW.
 
  • Informative
Reactions: Electrph
man i tried to get this stuff going in python and ran into the same problem i always do - i can never resolve all the dependencies properly because package names conflict and newer versions of packages seem to break the APIs willy-nilly.

does anyone have a venv config that satisfies all the dependencies in the code above?
I don’t have my PW installed yet, but we should build a simple docker for this. Complete with scripts / automation to pull periodic stats, and jupyter notebooks for the data aggregation and plotting.
 
  • Like
Reactions: astrorob
With all the knowledge of some folks, am waiting for one to take the challenge and make a self contained app that will do this for ANYONE, no computer knowledge needed. Anyone?
This is the best I can do that's as "easy" as possible, all done in a Chrome browser.
  • Using your gmail account create a new blank Google Sheet.
  • In your new blank Google Sheet open Tools > Script editor:
gsheet-script editor.png
  • When the Apps Script page loads in another tab, clear whatever is in there and paste in this code, and save. I noticed that sometimes my browser hangs and you just have to close the tabs and reload the Google Sheet and repeat it until it comes up.
google apps script.png
  • Refresh the tab with your Google Sheet and you should see a new option appear called Custom Menu:
gsheet-custom menu.png
  • If you click on Custom Menu > Get Products, the first time it's going to ask you to authorize access for this script through a series of pages:
gsheet-auth 1.png
Click Continue.​

gsheet-auth 2.png
Pick the gmail account you want to use, if more than one.​

gsheet-auth 3.png
Click Advanced.​
gsheet-auth 4.png
Click Go to Untitled project.​
gsheet-auth 5.png
Click Allow.​
  • After you finish the Google authentication steps, one time only, it will show a pop-up asking for your access token. You can get your access token here (use at your own risk) but be careful not to save it where anyone can access it as it will grant full access to your Tesla products - solar, powerwall, and vehicles.
  • It will print out the data starting in whichever cell your cursor is in. You can add as many sheets as you want on bottom left corner with the + symbol, Add Sheet, and execute whichever of the Custom Menu items you want to print out data from Tesla API.

If you think it's easy enough, I can add more API calls in the Custom Menu over time. You'll just have to pick the the latest code in GitHub and paste over what was there previously in the Script Editor, save, and reload your Google Sheet.
 

Attachments

  • gsheet-script editor.png
    gsheet-script editor.png
    171.6 KB · Views: 153
This is the best I can do that's as "easy" as possible, all done in a Chrome browser.
  • Using your gmail account create a new blank Google Sheet.
  • In your new blank Google Sheet open Tools > Script editor:
  • When the Apps Script page loads in another tab, clear whatever is in there and paste in this code, and save. I noticed that sometimes my browser hangs and you just have to close the tabs and reload the Google Sheet and repeat it until it comes up.
  • Refresh the tab with your Google Sheet and you should see a new option appear called Custom Menu:
  • If you click on Custom Menu > Get Products, the first time it's going to ask you to authorize access for this script through a series of pages:
View attachment 670239 Click Continue.​

View attachment 670240 Pick the gmail account you want to use, if more than one.​

View attachment 670241 Click Advanced.​
View attachment 670244 Click Go to Untitled project.​
View attachment 670245 Click Allow.​
  • After you finish the Google authentication steps, one time only, it will show a pop-up asking for your access token. You can get your access token here (use at your own risk) but be careful not to save it where anyone can access it as it will grant full access to your Tesla products - solar, powerwall, and vehicles.
  • It will print out the data starting in whichever cell your cursor is in. You can add as many sheets as you want on bottom left corner with the + symbol, Add Sheet, and execute whichever of the Custom Menu items you want to print out data from Tesla API.

If you think it's easy enough, I can add more API calls in the Custom Menu over time. You'll just have to pick the the latest code in GitHub and paste over what was there previously in the Script Editor, save, and reload your Google Sheet.

This worked great, thanks for taking the time to write it up and provide screenshots!

Just a couple of notes of what I noticed.

1. informational only, and you know this, but for anyone reading along, this requires both the chrome browser and a free gmail account. I believe you need a google / gmail account in order to get access to google sheets. The account is free and can be created in just a few minutes, but you need the chrome browser and the google account.

2. Following along with your instructions, After pasting the script, when I went back to the google sheet and refreshed it, and there was no custom menu that appeared. I refreshed a few times but still no custom menu. I went back to the tab with the script in it, clicked "RUN" in the menu at the top, which started running the script.

The approval / authorization steps then appeared, and after going through that and toggling back to the google sheet and refreshing, the custom menu then appeared. Pasting my pre generated token in there works in the get products (which shows my car as well, as expected), and the other choices work as well.

Thank you so much for putting this together!
 
i got the spreadsheet going as well - thanks for that.

at first it seemed to be reporting proper info, but today i checked and although the tesla app and the local API say that the powerwall is charged to 100%, in the spreadsheet i see:


energy_left21336.63158
total_pack_energy27064
percentage_charged78.83768689
battery_typeac_powerwall
backup_capableTRUE
battery_power990

this data is wrong or at least stale... the current battery power is -5W according to the local API.

is this a known problem with the spreadsheet? i tried closing the tab and re-opening the document but the behavior was the same.

also if the data were correct, and the powerwall is charged to 100%, is the "energy_left" equal to the current capacity of the powerwalls? meaning it would report something less than 27000wh which would reflect the state of degradation?

rob
 
also if the data were correct, and the powerwall is charged to 100%, is the "energy_left" equal to the current capacity of the powerwalls? meaning it would report something less than 27000wh which would reflect the state of degradation?

rob
Yes, the energy_left will reflect the current pack capacity at 100%. However, the total_pack_energy also shows the maximum current pack capacity, so it's easier just to read that. At 100%, energy_left and total_pack_energy are the same.
 
i got the spreadsheet going as well - thanks for that.

at first it seemed to be reporting proper info, but today i checked and although the tesla app and the local API say that the powerwall is charged to 100%, in the spreadsheet i see:


energy_left21336.63158
total_pack_energy27064
percentage_charged78.83768689
battery_typeac_powerwall
backup_capableTRUE
battery_power990

this data is wrong or at least stale... the current battery power is -5W according to the local API.

is this a known problem with the spreadsheet? i tried closing the tab and re-opening the document but the behavior was the same.

also if the data were correct, and the powerwall is charged to 100%, is the "energy_left" equal to the current capacity of the powerwalls? meaning it would report something less than 27000wh which would reflect the state of degradation?

rob
The battery power difference is probably a timing issue as I'm noticing it changes frequently over a wide range.

The difference in the percentage_charged is weird because that doesn't change quickly. Do you have more than 1 Powerwall? Oh by the way, I wasn't explicit about this but the data doesn't automatically update. You have re-run the command from the custom menu every time you want the data refreshed, so reloading the spreadsheet won't change anything. If you want it to refresh every time you reload, the script has to be re-written to store the access token, which you may not want to do.

I'm not certain but to better understand battery degradation, you should track the total_pack_energy over time. I assume this because I think the 3 variables will always tie out, even if the battery degrades, i.e. total_pack_energy = energy_left * percentage_charged / 100
 
Last edited:
The battery power difference is probably a timing issue as I'm noticing it changes frequently over a wide range.

The difference in the percentage_charged is weird because that doesn't change quickly. Do you have more than 1 Powerwall? Oh by the way, I wasn't explicit about this but the data doesn't automatically update. You have re-run the command from the custom menu every time you want the data refreshed, so reloading the spreadsheet won't change anything. If you want it to refresh every time you reload, the script has to be re-written to store the access token, which you may not want to do.

I'm not certain but to better understand battery degradation, you should track the total_pack_energy over time. I assume this because I think the 3 variables will always tie out, even if the battery degrades, i.e. total_pack_energy = energy_left * percentage_charged / 100

i have a 2-powerwall system. yes - i understood that the command needs to be re-run each time - in fact i was clearing out the spreadsheet before each run since there seem to be differences in what is returned by the "get products" command from run to run which makes a mess out of the display. i just mentioned that i closed and reloaded the tab since i was hoping that would kill the script interpreter and restart it just so that it would be starting fresh with no stale data. of course if that's all running in google's cloud then closing the tab doesn't necessarily do anything.

anyhow the data from "get products" was wildly wrong when i checked it that 2nd time as noted above. however, i just checked the spreadsheet now and it's roughly correct - SOC in the spreadsheet is 75% while the PW itself is reporting 78.5% and the app says 78% as well. the charging current is roughly correct as well. not sure why the discrepancy as i would have thought the app and the spreadsheet are pulling the data from the same place (though i guess the app does do some weird scaling with the percentage display, or so i've read.)

anyway it looks like i can pull total_pack_energy to keep track of the degradation. i'm surprised that it's still reading ~27000 as this is roughly the nominal capacity of a two-PW system. this thing has been cycled daily between 100% and 50% for about 6 months.

i wonder if this stuff is also available from the PW local API? i just got the homebridge-powerwall module going and it seems to be able to spoof elgato devices such that a history of various parameters is kept in homekit. if i could hack in total_pack_energy to that code then i'd be set.
 
  • Like
Reactions: Gwgan
i have a 2-powerwall system. yes - i understood that the command needs to be re-run each time - in fact i was clearing out the spreadsheet before each run since there seem to be differences in what is returned by the "get products" command from run to run which makes a mess out of the display. i just mentioned that i closed and reloaded the tab since i was hoping that would kill the script interpreter and restart it just so that it would be starting fresh with no stale data. of course if that's all running in google's cloud then closing the tab doesn't necessarily do anything.

anyhow the data from "get products" was wildly wrong when i checked it that 2nd time as noted above. however, i just checked the spreadsheet now and it's roughly correct - SOC in the spreadsheet is 75% while the PW itself is reporting 78.5% and the app says 78% as well. the charging current is roughly correct as well. not sure why the discrepancy as i would have thought the app and the spreadsheet are pulling the data from the same place (though i guess the app does do some weird scaling with the percentage display, or so i've read.)

anyway it looks like i can pull total_pack_energy to keep track of the degradation. i'm surprised that it's still reading ~27000 as this is roughly the nominal capacity of a two-PW system. this thing has been cycled daily between 100% and 50% for about 6 months.

i wonder if this stuff is also available from the PW local API? i just got the homebridge-powerwall module going and it seems to be able to spoof elgato devices such that a history of various parameters is kept in homekit. if i could hack in total_pack_energy to that code then i'd be set.
This, and more data, is available directly from the gateway. This is probably the best and most comprehensive documentation of it I've see so far: vloschiavo/powerwall2
 
The difference in the percentage_charged is weird because that doesn't change quickly. Do you have more than 1 Powerwall? Oh by the way, I wasn't explicit about this but the data doesn't automatically update.

my PW is now at 95% capacity and i'm seeing similar weird values again:

energy_left20552.47368
total_pack_energy27103
percentage_charged75.83099171

my PW was in a similar state the other day when i first noticed this. so somewhere along the line stuff is getting corrupted if the SOC is high...?
 
my PW is now at 95% capacity and i'm seeing similar weird values again:

energy_left20552.47368
total_pack_energy27103
percentage_charged75.83099171

my PW was in a similar state the other day when i first noticed this. so somewhere along the line stuff is getting corrupted if the SOC is high...?
I'm truly baffled by this as these API's are the same way the mobile app gets this data to show. Out of curiosity, do you get the same values for those 3 attributes when you run "Get Site Status" vs. "Get Site Live Status"?
 
i agree, it should just work. i can try a different browser just to see if there's any difference. next time it is acting up i'll also check the site status/live status and see what it says.
Ok thanks, let me know if there is a difference. Also, I added 2 more API calls "Get Battery Status" and "Get Battery Data" if you want to try those calls using the battery ID ("id" from Get Products) and see if that shows any difference. You'll have to grab the updated code from GitHub and overwrite the code in your Script Editor, save, and reload the Google Sheet.
 
ok, even on the old script code, when the values returned in "Get Products" are wrong, they are correct in "Get Site Live Status" and "Get Site Status". so i think this is just a bug on tesla's side and most likely means that the tesla apps are using "Get Site*Status" when reporting info.

i was just using Get Products as it results in one fewer dialog box, but i could just hack the script to put in my energy site ID.
 
  • Like
Reactions: mjhwa