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.
Bump:

(Moderator note: community thoughts on making this thread a sticky, or, someone who has knowledge around this writing up a "how to" post for me to make a sticky post?"
What kind of format/table of contents were you thinking? There is already a site that describes all the Tesla API endpoints but maybe you're thinking more of a tutorial style?
 
What kind of format/table of contents were you thinking? There is already a site that describes all the Tesla API endpoints but maybe you're thinking more of a tutorial style?

Yeah, I was thinking more tutorial style like a couple of members have posted like "download this, run this command". Something fairly simple. I know a lot of members here have created dashboards and such but that wasnt what I was thinking... just more along the lines of what @gpez posted in post number 10 in this thread.
 
  • Like
Reactions: Electrph and h2ofun
Ah I see. The hardest part is getting the authentication token, now that Tesla has changed the method. I did make a tutorial video about it
Yeah, I was thinking more tutorial style like a couple of members have posted like "download this, run this command". Something fairly simple. I know a lot of members here have created dashboards and such but that wasnt what I was thinking... just more along the lines of what @gpez posted in post number 10 in this thread.

Access Token​

The hardest part is getting the authentication token, now that Tesla has changed the method, you unfortunately can't run off a simple command anymore. The steps and syntax for Python 2.7 is in here. If you run that in python it will prompt you for your email, password, and MFA passcode, then print out the token. Be careful to protect that as it will give anyone full access to your vehicles and Powerwalls.

API Commands​

Almost all the Tesla API's are documented in this reference site. You'll need 2 identifiers to access the Tesla Energy API commands: Site ID and Battery ID. Using your access token and Python you can find those values imbedded in the JSON object returned:

Python:
    url = 'https://owner-api.teslamotors.com/api/1/products'

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )

    print(response)

Site​

Now with those identifiers, you can call all the other commands to get data or send commands:
Python:
    url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
              + site_id
              + '/live_status')

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )
    
    print(response)

Powerwall​

Python:
    url = ('https://owner-api.teslamotors.com/api/1/powerwalls/'
              + battery_id
              + '/status')

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )

    print(response)
 
(moderator note)

@mjhwa Thank you very much for that information. Between that and the other information in this thread already, I decided to make it a sticky thread so it doesnt get lost. There are going to be plenty of people who are smart, but not quite as technical, who will benefit from any information on how to do this.
 
  • Like
Reactions: h2ofun
Which API's are used to create the different cards in the Tesla Mobile App:

Cards​

API​

IMG_5852.png
Python:
    url = ('https://owner-api.teslamotors.com/api/1/powerwalls/'
              + BATTERY_ID
              + '/powerhistory')

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )

    print(response)
IMG_5876.png
IMG_5904.png
IMG_5903.png
Python:
    url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
              + SITE_ID
              + '/history'
              + '?kind=energy'
              + '&period=' + period
             )

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )
    
    print(response)
IMG_5906.png
Python:
    url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
              + SITE_ID
              + '/calendar_history'
              + '?kind=time_of_use_energy'
              + '&period=' + period
              + '&end_date=' + datetime.strftime(date, '%Y-%m-%dT06:59:59Z')
             )

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )
    
    print(response)
IMG_5905.png
Python:
    url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
              + SITE_ID
              + '/calendar_history'
              + '?kind=savings'
              + '&period=' + period
              + '&start_date=' + datetime.strftime(date, '%Y-%m-%dT00:00:00Z')
              + '&end_date=' + datetime.strftime(date, '%Y-%m-%dT23:59:59Z')
              + '&tariff=' + tariff_id
             )

    response = json.loads(
      requests.get(
        url,
        headers={'authorization': 'Bearer ' + ACCESS_TOKEN}
      ).text
    )
    
    print(response)
 
Umm. What about just noting (1) what percent it is at at midnight and (2) kWh discharged until solar takes over at whenever o’clock in the am, the (3) calculate.

one could make it easy by setting it to total back up so it’s at 100% at midnight and then the app does the rest?

yes? No?
For example, my 3 PWs ought to equal about 40kwh. If I note where it is at midnight then by say 8 am it’s down 50% that should be 20kwh.

if the app shows only 15kwh discharged and 50% down then it’s degradation.
 
Umm. What about just noting (1) what percent it is at at midnight and (2) kWh discharged until solar takes over at whenever o’clock in the am, the (3) calculate.

one could make it easy by setting it to total back up so it’s at 100% at midnight and then the app does the rest?

yes? No?
For example, my 3 PWs ought to equal about 40kwh. If I note where it is at midnight then by say 8 am it’s down 50% that should be 20kwh.

if the app shows only 15kwh discharged and 50% down then it’s degradation.
Doesn't using total_pack_energy work, as posted here? If not you can always take energy_left / percentage_charged, though I suspect you'll get the exact figure as total_pack_energy. It's the same calculation you're suggesting above but not time dependent.
 
Yeah, I was thinking more tutorial style like a couple of members have posted like "download this, run this command". Something fairly simple. I know a lot of members here have created dashboards and such but that wasnt what I was thinking... just more along the lines of what @gpez posted in post number 10 in this thread.
Is it possible to add a step by step / how to for those (few?) of us on here with zero programming experience ... or should we not even be attempting this ? . when i mean basic i mean i had to google api and when you say curl command ... no idea 😄
 
  • Like
Reactions: h2ofun
Is it possible to add a step by step / how to for those (few?) of us on here with zero programming experience ... or should we not even be attempting this ? . when i mean basic i mean i had to google api and when you say curl command ... no idea 😄

Im not a programmer (but I am in IT) and @gpez post #10 in this thread is the closest. I used a mac as curl was already installed on that. I am not qualified to post such a walkthrough myself, but maybe someone will post one.
 
Im not a programmer (but I am in IT) and @gpez post #10 in this thread is the closest. I used a mac as curl was already installed on that. I am not qualified to post such a walkthrough myself, but maybe someone will post one.
yea i am so distant from being that computer savy i dont even know proper term .. should have said zero computer background other than end user haha
 
Doesn't using total_pack_energy work, as posted here? If not you can always take energy_left / percentage_charged, though I suspect you'll get the exact figure as total_pack_energy. It's the same calculation you're suggesting above but not time dependent.

Guys,

For all you programmers I mean, I am impresssed, however, you can just use the app.

It expresses as a percentage of PWs and the other screen shows to and from PWs (that day) in Kwh.

Just figure out how many Kwh your PWs should have, for me its 3 x 13.5 about 40.

Every ten percent ought to be about 4.

Today at about noon I was at 70%, and 18kwh had gone "to PW"

To get to 100% with no degradation is 30%, or 12kwh more.

I checked and when it got to 100% it was 29.7 "to PW"

No degredation yet, within about .3 of a kwh or so. But you don't need to program anything, I think.

At least its good enough to know if there are where they should be.

If I do this five years from now and the "to PW" is only 10kwh instead of 12kwh to get from 70% t0 100% then I have had some degredation and can look further.
 
Guys,

For all you programmers I mean, I am impresssed, however, you can just use the app.

It expresses as a percentage of PWs and the other screen shows to and from PWs (that day) in Kwh.

Just figure out how many Kwh your PWs should have, for me its 3 x 13.5 about 40.

Every ten percent ought to be about 4.

Today at about noon I was at 70%, and 18kwh had gone "to PW"

To get to 100% with no degradation is 30%, or 12kwh more.

I checked and when it got to 100% it was 29.7 "to PW"

No degredation yet, within about .3 of a kwh or so. But you don't need to program anything, I think.

At least its good enough to know if there are where they should be.

If I do this five years from now and the "to PW" is only 10kwh instead of 12kwh to get from 70% t0 100% then I have had some degredation and can look further.
i agree decent rough estimate .. if see trending down can have tesla pull numbers ... would be nice to see actual report without all the api query etc
 
Im not a programmer (but I am in IT) and @gpez post #10 in this thread is the closest. I used a mac as curl was already installed on that. I am not qualified to post such a walkthrough myself, but maybe someone will post one.
In my opinion, the simplest way to get into this API programming is by using Google Apps Script. You don't need a specific type of hardware, operating system, or server. You just need a browser, preferably Chrome, and an internet connection. Best of all, this service is free!

I started by doing a couple of the simple tutorials they offered to get used to how things work and then applied it to the Tesla API. Unfortunately you still need to do the programming. If anyone is interested, after getting familiar with the sample Google tutorials, I created a series of YouTube videos on how to get the Tesla API's to work with Google Apps Script.
 
Is it possible to add a step by step / how to for those (few?) of us on here with zero programming experience ... or should we not even be attempting this ? . when i mean basic i mean i had to google api and when you say curl command ... no idea 😄
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?
 
Guys,

For all you programmers I mean, I am impresssed, however, you can just use the app.

It expresses as a percentage of PWs and the other screen shows to and from PWs (that day) in Kwh.

Just figure out how many Kwh your PWs should have, for me its 3 x 13.5 about 40.

Every ten percent ought to be about 4.

Today at about noon I was at 70%, and 18kwh had gone "to PW"

To get to 100% with no degradation is 30%, or 12kwh more.

I checked and when it got to 100% it was 29.7 "to PW"

No degredation yet, within about .3 of a kwh or so. But you don't need to program anything, I think.

At least its good enough to know if there are where they should be.

If I do this five years from now and the "to PW" is only 10kwh instead of 12kwh to get from 70% t0 100% then I have had some degredation and can look further.

I was easy for me to do using the app, but I also wanted to see what "the system" thought it had. because I have an EV, it was fairly easy for me to, after driving to work and back, set my EV to charge at 3 in the morning, and turn my reserve down to zero in the app. Then, because my production right now is about double my normal daily usage, simply let my PV fill my powerwalls (2) to full and see what that number was.

No math needed at all, lol. I wanted a way to validate that result, because I was aware there was information about what the powerwall thought it had, which was returned via the curl commands that @gpez had.

In my case, as I have said in another thread, I have 21% degradation after 17 months or so.

As for "create an app" there is an app already, the tesla app, lol. You are asking for the wrong thing, imo. You dont want an app. You want one of them to create a custom dashboard, but then you end up with needing it to be self hosted like they have done, or possibly worrying about where your tesla token is being used.
 
  • Like
Reactions: Southpasfan
I was easy for me to do using the app, but I also wanted to see what "the system" thought it had. because I have an EV, it was fairly easy for me to, after driving to work and back, set my EV to charge at 3 in the morning, and turn my reserve down to zero in the app. Then, because my production right now is about double my normal daily usage, simply let my PV fill my powerwalls (2) to full and see what that number was.

No math needed at all, lol. I wanted a way to validate that result, because I was aware there was information about what the powerwall thought it had, which was returned via the curl commands that @gpez had.

In my case, as I have said in another thread, I have 21% degradation after 17 months or so.

As for "create an app" there is an app already, the tesla app, lol. You are asking for the wrong thing, imo. You dont want an app. You want one of them to create a custom dashboard, but then you end up with needing it to be self hosted like they have done, or possibly worrying about where your tesla token is being used.
Call it what you want, just something for us dummies
 
I was easy for me to do using the app, but I also wanted to see what "the system" thought it had. because I have an EV, it was fairly easy for me to, after driving to work and back, set my EV to charge at 3 in the morning, and turn my reserve down to zero in the app. Then, because my production right now is about double my normal daily usage, simply let my PV fill my powerwalls (2) to full and see what that number was.

No math needed at all, lol. I wanted a way to validate that result, because I was aware there was information about what the powerwall thought it had, which was returned via the curl commands that @gpez had.

In my case, as I have said in another thread, I have 21% degradation after 17 months or so.

As for "create an app" there is an app already, the tesla app, lol. You are asking for the wrong thing, imo. You dont want an app. You want one of them to create a custom dashboard, but then you end up with needing it to be self hosted like they have done, or possibly worrying about where your tesla token is being used.
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 was easy for me to do using the app, but I also wanted to see what "the system" thought it had. because I have an EV, it was fairly easy for me to, after driving to work and back, set my EV to charge at 3 in the morning, and turn my reserve down to zero in the app. Then, because my production right now is about double my normal daily usage, simply let my PV fill my powerwalls (2) to full and see what that number was.

No math needed at all, lol. I wanted a way to validate that result, because I was aware there was information about what the powerwall thought it had, which was returned via the curl commands that @gpez had.

In my case, as I have said in another thread, I have 21% degradation after 17 months or so.

As for "create an app" there is an app already, the tesla app, lol. You are asking for the wrong thing, imo. You dont want an app. You want one of them to create a custom dashboard, but then you end up with needing it to be self hosted like they have done, or possibly worrying about where your tesla token is being used.
Huh,

That's a lot for 17 months. Unless it just levels off some replacement PWs in the future.

I have not seen anything similar in my two year old Model 3.

My six year old egolf is at 90 something percent of where it started.

What is interesting is the car batteries are constantly cycled.
 
Huh,

That's a lot for 17 months. Unless it just levels off some replacement PWs in the future.

I have not seen anything similar in my two year old Model 3.

My six year old egolf is at 90 something percent of where it started.

What is interesting is the car batteries are constantly cycled.
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.