[tesla]/[teslapowerwallcloud] Time to think about Fleet API

Link to the binding that uses FleetAPI - https://smedley.id.au/tesla/org.openhab.binding.tesla-4.1.2-SNAPSHOT.jar

NB: Existing ownerapi refresh tokens will NOT work.

You either need to:

  1. Register your own client id and install your own proxy, using the instructions at https://developer.tesla.com/docs/fleet-api?shell#overview
  2. Message me for a link to register your car using my client id and my proxy, noting that if/when Tesla start charging for open source projects to use the fleet api, I’ll kill this off.

The binding is the link above is updated to now include tyre pressure monitoring data, currently reported in bar (I’d prefer PSI!)

Hi @Paul_Smedley, cant we reverse engineer the proxy and add those requirements to the requests in the binding? Or perhaps host the proxy in OH instance?

I see this in the proxies github page:

If you are one of these developers, you can set up the proxy server or refactor your application to use this library directly.

someone cleverer than me might be able to do those things, my java is not great… enough to be able to tweak things, but not do anything too fancy…

Tried to setup on a new box with the latest binding, getting weird errors like:

2024-04-15 19:06:56.555 [WARN ] [ore.internal.thing.ThingTypeResource] - Cannot find channel type: tesla:tripcharging

Not sure why it’s looking for tesla:tripcharging and not just tripcharging

Edit2: I fixed this - I had stuffed up channels.xml.

Sending commands stopped working some days ago. With debug-logging I get this 502 errors:

2024-05-12 13:01:27.869 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2024-05-12 13:01:27.873 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN 5YJ3E7EA5LFXXXXXX
2024-05-12 13:01:27.876 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle state is online
2024-05-12 13:01:27.879 [DEBUG] [internal.handler.TeslaVehicleHandler] - Car has not moved in 5 min, and can sleep
2024-05-12 13:01:27.881 [DEBUG] [internal.handler.TeslaVehicleHandler] - Car has not moved in 5 min, and can sleep
2024-05-12 13:01:27.882 [DEBUG] [internal.handler.TeslaVehicleHandler] - Throttled state polling to allow sleep, occupied/idle, or in a console mode
2024-05-12 13:01:33.034 [DEBUG] [internal.handler.TeslaVehicleHandler] - handleCommand tesla:vehicle:d756a5f7e0:5YJ3E7EA5LFXXXXXX:autoconditioning OFF
2024-05-12 13:01:33.036 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: auto_conditioning_stop
2024-05-12 13:01:35.271 [DEBUG] [internal.handler.TeslaAccountHandler] - An error occurred while communicating with the vehicle during request auto_conditioning_stop: 502: Bad Gateway
2024-05-12 13:01:58.290 [DEBUG] [internal.handler.TeslaVehicleHandler] - handleCommand tesla:vehicle:d756a5f7e0:5YJ3E7EA5LFXXXXXX:autoconditioning ON
2024-05-12 13:01:58.292 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: auto_conditioning_start
2024-05-12 13:01:59.669 [DEBUG] [internal.handler.TeslaAccountHandler] - An error occurred while communicating with the vehicle during request auto_conditioning_start: 502: Bad Gateway
2024-05-12 13:02:28.571 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2024-05-12 13:02:28.573 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN 5YJ3E7EA5LFXXXXXX
2024-05-12 13:02:28.577 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle state is online

Recieving data still works. @Paul_Smedley: Maybe the proxy needs a restart?

1 Like

same here.

1 Like

Try now… The machine running the proxy rebooted on Thursday and I didn’t realise the proxy wasn’t running :frowning:


Great, it’s working again!

Thank you Paul! Would you provide a manual to us, how to set up our own proxy?

I can try do this, but not sure when I’ll have time. I basically followed the instructions at Tesla Developer API Guide: HTTP-Proxy Server Integration (Part 4) | by Shankar Kumarasamy | Medium

By biggest issue is that even thought I can repeatably start the proxy from the command line, I can’t get it to start from a cron script so if my pin reboots for some reason, and I don’t remember, the proxy won’t be running.

I have a proxy server running in Docker now. But I have a problem due to a self signed certificate to send commands. Could you please provide a java version with --insecure option?

Caused by: java.net.http.HttpConnectTimeoutException: HttpConnectTimeoutException invoking https://homebks.xxxxxxx.org:4443/api/1/vehicles/5YJxxxxxx/command/set_charging_amps: HTTP connect timed out
at jdk.internal.reflect.GeneratedConstructorAccessor296.newInstance(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]

My SSL cert is also self-signed. I’m running a nginx proxy with letsencrypt to handle this.

ngix config is:
server {
listen 4443 ssl default_server;
listen [::]:4443 ssl default_server;
server_name smedley.id.au;
ssl_certificate /etc/letsencrypt/live/smedley.id.au/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/smedley.id.au/privkey.pem;

    location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;