Tesla API Access


#7

Thanks. I want to be able to detect when we are pulling from the powerwall exclusively for night time use and when we are pulling from the powerwall due to a power outage so I can put the house into different levels of some sort of high-efficiency mode. The solar hub is a zigbee device but I have no way of knowing how to gather what I need from it for a device handler.


#8

Yeah, I’m not sure what data is available from the API but I would try logging info from the HTTP requests shown here https://www.teslaapi.io/powerwalls/state-and-settings and see if it has what you need.

To be clear, I know this API incorporates Powerwall data, but I don’t know if it’s somehow limited to Powerwalls used in conjunction with Tesla vehicles. If there’s a separate and unique Powerwall API available for Powerwall-only owners, I’m not familiar with it.


#9

Perfect. Disappointing the only way to access responses is via parsing the text.


#10

Parsing a response from at HTTP request is standard with almost any API. And in webCoRE it’s very easy to do.


#11

I see that now in your second piston. Thanks. Got it all working but there is not much I can really do with it until Tesla fixes a communication issue between one of my controllers and the hub.


#12

Building on bthrock’s good work, I have written a piston to query and log the Powerwall’s data


#14

Having a pop at this but i’m getting the following error messages when I click “Test” any ideas?

Error executing virtual command [].setVariable: (5ms) groovy.lang.MissingPropertyException:     No such property: result for class: script_app_6c4a97a42cd9c01ed79ae72c875a75bf6c50e82c665272109ecaf6627b713546
+1156ms	║Error executing virtual command [].setVariable: (1ms) groovy.lang.MissingPropertyException: No such property: result for class: script_app_6c4a97a42cd9c01ed79ae72c875a75bf6c50e82c665272109ecaf6627b713546
+1170ms	║An error occurred while executing the event: java.lang.NullPointerException: Cannot get property 'v' on null object

#15

@bthrock Any ideas bud as to why i’m getting that error message and not generating the tokens?


#16

Sorry, I’ve been out of the country for two weeks and away from any cell or wi-fi service for most of that time. I’ll try to take a look in a day or two, but I may need to see a full log along with green snapshot with trace enabled to identify the problem.


#17

I am assuming that you have not made any modifications to the piston other than to enter the values for your email and password (lines 22 and 23 in the piston as posted above). Those are the only changes necessary. If you have entered them correctly, the piston should work. If not, you should be getting an ‘unauthorized error.’

The MissingPropertyException suggests that something else has changed. You could simply reimport the piston and try again. Alternately, post a GREEN snapshot (blurring your email & password, of course) and a full log, and we should be able to get this working. :smiley:


#18

Hi!

I did try reimporting again just in case - I get this menu when first importing which i’ve just clicked ignore on.

Here is my green button output

And here is the full log

|+1ms|╔Received event [Home].test = 1575485994931 with a delay of 0ms|
| --- | --- |
|+135ms|║RunTime Analysis CS > 20ms > PS > 94ms > PE > 21ms > CE|
|+138ms|║Runtime (50659 bytes) successfully initialized in 94ms (v0.3.110.20191009) (137ms)|
|+139ms|║╔Execution stage started|
|+144ms|║║Cancelling statement #2's schedules...|
|+173ms|║║Sending external web request to: owner-api.teslamotors.com/oauth/token/|
|+1092ms|║║Executed virtual command httpRequest (938ms)|
|+1102ms|║║Calculating (integer) 1 + (integer) 13 >> (integer) 14|
|+1107ms|║║Error executing virtual command [].setVariable: (1ms) groovy.lang.MissingPropertyException: No such property: result for class: script_app_6c4a97a42cd9c01ed79ae72c875a75bf6c50e82c665272109ecaf6627b713546|
|+1119ms|║║Calculating (integer) 80 + (integer) 11 >> (integer) 91|
|+1130ms|║║Calculating (integer) 103 + (integer) 11 >> (integer) 114|
|+1134ms|║║Calculating (decimal) 1.575485995E9 + (decimal) 3888000.0 >> (decimal) 1.579373995E9|
|+1137ms|║║Calculating (decimal) 1.579373995E9 * (decimal) 1000.0 >> (decimal) 1.579373995E12|
|+1140ms|║║Error executing virtual command [].setVariable: (1ms) groovy.lang.MissingPropertyException: No such property: result for class: script_app_6c4a97a42cd9c01ed79ae72c875a75bf6c50e82c665272109ecaf6627b713546|
|+1144ms|║║Cancelling statement #15's schedules...|
|+1153ms|║║An error occurred while executing the event: java.lang.NullPointerException: Cannot get property 'v' on null object|
|+1170ms|║╚Execution stage complete. (1031ms)|
|+1180ms|║Setting up scheduled job for Thu, Dec 5 2019 @ 12:00:00 AM GMT (in 18003.889s)|
|+1190ms|╚Event processed successfully (1190ms)|
|04/12/2019, 18:59:42 +311ms|
|+715ms|║An error has occurred while subscribing: physicalgraph.exception.StateCharacterLimitExceededException: State cannot be greater than 100000.0 characters|

#19

Please use the upload button in the message editor to insert your images in place of the dropbox links.


#20

For reference:

pic


#21

I did try but unfortunately it wasn’t working in my browser


#22

Edit: Sorted now, used another browser.


#23

Your piston works fine. Did you remember to create the three global variables (@accessToken, @tokenExpiration, and @vehicleID)? Make sure the names match exactly, including capitalization.


#24

I’ve edited the green image now!

How do I create the global values? I’m not sure I did I thought I only needed to add my e-mail and password.

Edit: Ahhh you need to add those to the “global variables” box in the top right. Now it makes sense! Thanks


#25

Hi i’m looking to control heat seat. I’m unable to send parameter.

piston work for command without parameter.

thanks


#26

Although I haven’t tried that particular command, the request is pretty straightforward. When you create your web request, use POST and set variables for heater and level.

/api/1/vehicles/{id}/command/remote_seat_heater_request


#27

Hi @bthrock, sorry to bother you but I need some guidance on the execution of the second piston. I ran the first piston successfully since all global variables were populated but when running the second one, it seems that it’s returning an error (I was hopping it would log the charge state, battery level, etc). I took a screenshot of the log for your reference. Is there something I am doing wrong? Any help would be appreciated. Thanks again!