Unable to setup Teslaproxy - driving me crazy

I’m trying to setup Teslaproxy as I want to control (at home) the charging speed of the car and only charge when the energy price is low. But this addon is driving me crazy. I believe I’m following all the steps but still no luck.

Situation:

  • NGINX Home Assistant SSL proxy has been installed with the following config:
    domain: xxxxxxxxxx.hopto.org
    hsts: max-age=31536000; includeSubDomains
    certfile: fullchain.pem
    keyfile: privkey.pem
    cloudflare: false
    customize:
    active: false
    default: nginx_proxy_default*.conf
    servers: nginx_proxy/*.conf
    real_ip_from:

  • Letsencrypt is installed and configured as:

domains:

  • xxxxxxxxxx.hopto.org
    email: [email protected]
    keyfile: privkey.pem
    certfile: fullchain.pem
    challenge: http
    dns: {}

  • I also have the TeslaFleet installed and running.

  • The TeslaProxy has the following configuration:
    client_id: xxxxxxxxxxxxxxxxxxxx
    client_secret: xxxxxxxxxxxxxxxxxxxx
    domain: xxxxxxxxxx.hopto.org
    debug: true
    regenerate_auth: true
    region: Europe, Middle East, Africa

  • Port 80 and 443 on my modem are forwarded to Home Assistant.

  • I’ve created an App in the Tesle development environment.

  • What I don’t know where to copy the Tesla key pair which needs to be generated according to the Tesla instructions. Or is the TeslaProxy doing this for you?

  • I also notices that the TeslaProxy is automatically generating/registering the Home Assistant App in the Tesla Development portal!

  • At some stage I need to scan the QR code with the mobile phone to grant access to the thrid party app but then I get the following error message in the Tesla mobile phone app:
    IMG_0507

Any suggestions on what the problem could be?

I’m with you. Driving me crazy. I likely cannot help you, but just verify if you’re in exactly same spot as I am - getting the same error message in the Tesla app, but I believe I have found the problem - not the solution though.

  1. Go to address https://xxxxxxxxxx.hopto.org/.well-known/appspecific/com.tesla.3p.public-key.pem
    …I’m getting a 404 file not found, although I can access my HA from internet using https://mysite.domain.org.

  2. In your installation there should be folder /share/nginx_proxy and /share/tesla. In the latter folder you should find the pem file mentioned above. Note that the folders are not in the HA/config folder but in your smb://[ip-address]/share.

Conclusion:
…now, to me the problem is that the com.tesla.3p.public_key.pem exists in the correct location, but for some reason it is not accessible from internet. I would think this is either a nginx issue, or that teslaproxy failed to create a proper link from .well-known/appspecific/ to the /share/tesla folder - but I’m no programmer. Though it is clear that if the integration cannot access the public key (.pem file) the integration cannot work.

Please let me know if this is the case also with you. If so, I’d think it’s not a one-off user problem, but something to do in some environments and should be in the documentation.

I managed to get it working. Couple of things I ran into:

  • Make sure you follow the steps in every little detail. Executing one step with a type leads in generating the wrong certificates which you cannot easily redo by simply fixing the typo and start again.
  • Indeed the nginx config is important, the two domain names that you have the generate needs to point to two different locations within HA. I had to SSH into HA to set the nginx config correctly.
  • There are some “true” flags in the config which needs to be set correctly.

Now I can control the charging from HA.

I still have a challenge with the geolocation tracker of the car, when I get home with the Tesla it is not yet detected and the garage gate is not opened. Still working and debugging this situation.

No luck on my side. Reinstalled everything, deleted /share and even /ssl to regenerate certs.

What is bit concerning is that if I include in configuration.yaml the http: section with ssl_certificate and ssl_key, the remote access works ok (but no access to the tesla pem file). But if I, as per the instructions, don’t include those ssl fields, even the remote connection to HA doesn’t work (browser finds HA, but just stays in the 60sec “loading data” -screen forever). I though nginx should take care of the cert access - and they are indeed in the nginx configration.

Any idea if either the http2 warning, or the conflicting server name in the nginx log could be an issue?

[20:34:53] INFO: Running nginx...
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx.conf:30
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx.conf:54
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /share/nginx_proxy/nginx_tesla.conf:10
nginx: [warn] conflicting server name "myhome.duckdns.org" on 0.0.0.0:443, ignored

Well, some progress. The pem-file is accessible now. Only change I can think of that made this happen was that I changed the nginx domain name to something gibberish (like “jdgfölasedjfglajöfgvajöf” - with a duckdns.org suffix but I doubt that matters). Voilá, pem-file can be found. After this nginx can be set again to a real domain, if a remote access is wanted. And emphasizing, I don’t know if that did the job or just a coincidence. Anyway, step forward.

Next, installing and starting Tesla Custom Integration component. All good, until an error in the startup procedure.

DEBUG (MainThread) [teslajsonpy.connection] 412: {"error":"Account xxxxxxxxxxxx must be registered in the current region https://fleet-api.prd.eu.vn.cloud.tesla.com, please see https://developer.tesla.com/docs/fleet-api/endpoints/partner-endpoints#register"}

Tesla account is configured as Finland. Tested Tesla Proxy with NA/EU/Ch settings. Sigh.

Aaaand done.

Should’ve restarted the process further back, regenerating the Tesla authentication with Tesla Proxy, but hesitated as the public key was finally public. See 412: {"error":"Account xxx must be registered in the current region · llamafilm/tesla-http-proxy-addon · Discussion #155 · GitHub.