Closed dawiinci closed 3 years ago
This login method is no longer supported. Tesla has replaced captcha by recaptcha. Some module maintainers have decided to use a paid recaptcha solver service to support headless login. I decided to drop support for headless login and implement authentication though a real web browser or WebView. Please take a look at the readme for more information.
Thanks. Looks like it is working with selenium.
import teslapy
def solve_captcha(svg):
import webbrowser
import tempfile
# Use web browser to display SVG image
with tempfile.NamedTemporaryFile(suffix='.svg', delete=False) as f:
f.write(svg)
webbrowser.open('file://' + f.name)
indigo.server.log('#### Tesla: Login Captcha required')
indigo.actionGroup.execute(932264821) # notification
import time
time.sleep(10)
return str(indigo.variables[64356346].value)
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
def custom_auth(url):
with webdriver.Chrome() as browser:
browser.get(url)
WebDriverWait(browser, 300).until(EC.url_contains('void/callback'))
return browser.current_url
try:
with teslapy.Tesla(tesla_mail, authenticator=custom_auth, cache_file='/Users/server/Skripte/TeslaPy/cache.json') as tesla:
tesla.captcha_solver = solve_captcha
tesla.fetch_token()
vehicles = tesla.vehicle_list()
except:
indigo.server.log('#### Tesla: Login failed')
However, I am not sure if the captcha would work like this. I can't find anything on the re-captcha on your readme.
There is no captcha_solver
parameter anymore for the Tesla
class. The recaptcha will be shown by the browser controlled by selenium.
This code worked, but since yesterday it fails to login. No browser is opened for the captcha though. Any ideas? Car is online and accessible through the app.
The error appears instantly. If I delete the cache file there is no difference.