You can install our site as a web app on your iOS device by utilizing the Add to Home Screen feature in Safari. Please see this thread for more details on this.
Note: This feature may not be available in some browsers.
Good point. It might be because of that German teen who hacked 3rd party apps that held people's access token.
Make sure you're using UTC with the dates:I can't get time_of_use_energy to be recognized with start_date. It just sends "upstream internal errror" back.
kind=power still works for me except for the ever widening hole in the beginning of December.
url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
+ SITE_ID
+ '/calendar_history'
+ '?kind=time_of_use_energy'
+ '&period=' + period
+ '&start_date='
+ datetime.strftime(
s_date.astimezone(pytz.utc),
'%Y-%m-%dT%H:%M:%SZ')
+ '&end_date='
+ datetime.strftime(
e_date.astimezone(pytz.utc),
'%Y-%m-%dT%H:%M:%SZ')
)
Make sure you're using UTC with the dates:
Python 2.7:
url = ('https://owner-api.teslamotors.com/api/1/energy_sites/' + SITE_ID + '/calendar_history' + '?kind=time_of_use_energy' + '&period=' + period + '&start_date=' + datetime.strftime( s_date.astimezone(pytz.utc), '%Y-%m-%dT%H:%M:%SZ') + '&end_date=' + datetime.strftime( e_date.astimezone(pytz.utc), '%Y-%m-%dT%H:%M:%SZ') )
So this is using a start_date in local (Pacific) date/time Jan 12, 2022 00:00:00 and an end_date in local (Pacific) date/time Jan 12, 2022 23:59:59 then converting it to UTC into the URL below:Can you turn that into sample URL minus your token so that I can curl it. I'm using UTC times with Z on the end of the date/time string. Same as I'm using for end_date with kind=power.
So this is using a start_date in local (Pacific) date/time Jan 12, 2022 00:00:00 and an end_date in local (Pacific) date/time Jan 12, 2022 23:59:59 then converting it to UTC into the URL below:
https://owner-api.teslamotors.com/api/1/energy_sites/<SITE_ID>/calendar_history?kind=time_of_use_energy&period=day&start_date=2022-01-12T08:00:00Z&end_date=2022-01-13T07:59:59Z
I experienced the same. The access and refresh tokens are a much longer length and the access token expires in 8 hours instead of 45 days. You can use the same refresh token to generate a new access token more frequently now but the URL and parameters are different.
I read the article. It was not "hacked third party apps" it was "Found people who had used Teslamate, which is a SELF HOSTED tool, who had set it up incorrectly (likely not changing default passwords)".
I patched the data holes by downloading from the app for those days which was tedious and the resolution is in 100 watt increments so I'm likely to be off a few percent for those days unless they are leveling between the 5 minute increments with carryover and carryunder NOT to cross one hour boundaries.
Bummer... not that the tokens are longer, but they only last for 8 hours. Can you still use refresh tokens to generate new access tokens? That's easy enough to script. But the full reauthentication to generate new tokens is a pain due to the Captcha.
Oh yeah, that's a daily summary. For the 5 minute increments I use: /powerhistory but that only gets the previous day. There must be an endpoint that you can query for a particular day because it's available in the app.For me this "kind" isn't producing hourly data.
Yes though it's a bit different than before:Bummer... not that the tokens are longer, but they only last for 8 hours. Can you still use refresh tokens to generate new access tokens? That's easy enough to script. But the full reauthentication to generate new tokens is a pain due to the Captcha.
url = 'https://auth.tesla.com/oauth2/v3/token'
payload = {
'grant_type': 'refresh_token',
'client_id': 'ownerapi',
'refresh_token': REFRESH_TOKEN,
'scope': 'openid email offline_access'
}
Though I don't use calendar_history, kind=power, I played around with it and I was able to get data for period=day in 5 minute increments. Oddly enough nothing came up for Dec 9 but Dec 10 had values. Here's what I used:The data loss continues. Now the December 9th and 10th are gone.
local = pytz.timezone(TIME_ZONE)
date = local.localize(datetime(
date.year,
date.month,
date.day,
23,
59,
59,
0
), is_dst=None)
url = ('https://owner-api.teslamotors.com/api/1/energy_sites/'
+ SITE_ID
+ '/calendar_history'
+ '?kind=power'
+ '&end_date='
+ datetime.strftime(date.astimezone(pytz.utc), '%Y-%m-%dT%H:%M:%SZ')
+ '&period=' + period)
Though I don't use calendar_history, kind=power, I played around with it and I was able to get data for period=day in 5 minute increments. Oddly enough nothing came up for Dec 9 but Dec 10 had values. Here's what I used:
local = pytz.timezone(TIME_ZONE) date = local.localize(datetime( date.year, date.month, date.day, 23, 59, 59, 0 ), is_dst=None) url = ('https://owner-api.teslamotors.com/api/1/energy_sites/' + SITE_ID + '/calendar_history' + '?kind=power' + '&end_date=' + datetime.strftime(date.astimezone(pytz.utc), '%Y-%m-%dT%H:%M:%SZ') + '&period=' + period)
The data loss continues. Now the December 9th and 10th are gone.
Yes though it's a bit different than before
Yeah this changed a few months ago and I stopped trying to keep up with all the changes, relying on the refresh token. There's a long list of discussions on Tim Dorr's Github with varying solutions.I'm having trouble generating a new access token from the full 4 step login process outlined on this page:
Authentication | Tesla JSON API (Unofficial)
The authentication process for the Tesla APItesla-api.timdorr.com
Has Tesla changed this as well? It fails at Step 2. I do the login and get the Captcha at Step 1, but Step 2 to obtain an authorisation code returns
Access Denied
You don't have permission to access "http://auth.tesla.com/oauth2/v3/authorize?" on this server.