Tesla items not updated after some time

Hi Bill, thank you again for taking the time to help, I really appreciate it! The problem also occurs, if the car is asleep as I usually don’t use sentry mode at night and it still happens. I’ve tried the token generator you mentioned and will report back.

My Tesla bridge and car are also statically defined, if that matters.
You might also want to try installing a minimal openhab on vm in the cloud, outside of your ISP, to rule out WAF issues.

So, the token generator is not the problem. The problem still occurs. I don’t understand, why the access token can be retrieved initially but not during refresh.

When I added the new refresh token:

2022-09-07 17:45:06.229 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'tesla.things'
2022-09-07 17:45:06.314 [DEBUG] [internal.handler.TeslaAccountHandler] - Setting up an authenticated connection to the Tesla back-end
2022-09-07 17:45:06.315 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
2022-09-07 17:45:08.034 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the vehicle: Response: 200: OK

Refresh:

2022-09-08 01:45:07.374 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 401, Unauthorized
2022-09-08 01:45:07.375 [DEBUG] [internal.handler.TeslaVehicleHandler] - The access token has expired, trying to get a new one.
2022-09-08 01:45:07.376 [DEBUG] [internal.handler.TeslaAccountHandler] - Found a request token created at 2022-09-07 17:45:06
2022-09-08 01:45:07.377 [DEBUG] [internal.handler.TeslaAccountHandler] - The token has expired at 2022-09-07 18:13:54
2022-09-08 01:45:07.377 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
2022-09-08 01:45:07.390 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - An exception occurred while invoking a HTTP request: 'java.io.EOFException: HttpConnectionOverHTTP@928adce::DecryptedEndPoint@5868049e{l=/192.168.XX.XX:40958,r=auth.tesla.com/69.192.160.83:443,OPEN,fill=-,flush=-,to=28800593/0}'
2022-09-08 01:45:07.391 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - An error occurred during refresh of SSO token: no response
2022-09-08 01:45:07.391 [DEBUG] [internal.handler.TeslaVehicleHandler] - An error occurred while querying the vehicle

How often does your car wake up, if you’re not using it? The logs show that it’s online once an hour, although I’m using neither the app nor the car. I’m not sure if the binding is to blame, although “allow wake-ups” is false.

The car shouldn’t wake up if it is not charging, occupied, moving, or in some kind of console mode (dog, camp, etc…). If you have something else polling it maybe that would keep it awake and maybe over time the WAF doesn’t like the high frequency polling. Make sure you don’t have another copy of openhab or something like teslascope looking at it.

To see what the state is doing over a period time it may be better to graph it.


Number nTeslaState "nState [%d]"
Number nTeslaState_chart

where nTeslaState is calculated by this rule:

rule "Tesla State Changed"
    when
    Item TeslaState changed

    then
        if (previousState == NULL) return;
        switch (TeslaState.state) {
            case "online" : {
                nTeslaState.postUpdate(1)
            }
            case "asleep" : {
                nTeslaState.postUpdate(0)
            }
            case "offline" : {
                nTeslaState.postUpdate(-0.5)
            }
            case "waking" : {
                nTeslaState.postUpdate(0.5)
            }
            case "unknown" : {
                nTeslaState.postUpdate(-1)
            }

        }
end

Then you can do something like:

                Frame
                {
                            Switch label="State" item=nTeslaState_chart icon=line mappings=[0="Hide", 1="Hour", 2="Day", 3="Week", 4="Month"]
                                Chart  item=nTeslaState  period=h refresh=30000  visibility=[nTeslaState_chart==1]
                                Chart  item=nTeslaState  period=D refresh=30000  visibility=[nTeslaState_chart==2]
                                Chart  item=nTeslaState  period=W refresh=30000  visibility=[nTeslaState_chart==3]
                                Chart  item=nTeslaState  period=M refresh=30000  visibility=[nTeslaState_chart==4]
                }

Thanks again for the help. Ive already been using a state variable and a timestamp that is updated, whenever the car changes from “asleep” to “online” and vice versa. Over the last week, I watched the car and binding more closely (through debug logs) and think there’s something wrong with the binding or my configuration (I even cleared openHAB’s cache and tmp folders). I’m not using other services that use the Tesla API and I even closed the Tesla app during my tests. Nothing should prevent the car from sleeping or wake it up. I only know that strange things are going on, if I use the binding. Here are two excerpts from my log.

The car wakes up after sleeping for 10 minutes, although nothing should have woken it up. No app use, no physical interaction and the car certainly didn’t move. I don’t know what happens here and why (I manually marked the lines with state changes):

2022-09-08 16:41:35.447 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
2022-09-08 16:41:43.471 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:41:43.474 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:41:43.478 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
2022-09-08 16:41:50.449 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
2022-09-08 16:42:05.450 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
2022-09-08 16:42:20.451 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
2022-09-08 16:42:35.453 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is neither charging nor moving, skipping updates to allow it to sleep
**2022-09-08 16:42:46.531 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaState' changed from online to asleep**
2022-09-08 16:42:46.660 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaStateChangeTimestamp' changed from 2022-09-08T16:20:31.479529+0200 to 2022-09-08T16:42:46.656414+0200
2022-09-08 16:42:46.525 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:42:46.528 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:43:46.743 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:43:46.745 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:44:50.516 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:44:50.518 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:45:53.673 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:45:53.676 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:46:56.343 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:46:56.345 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:47:59.325 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:47:59.326 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:47:59.327 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is inactive
2022-09-08 16:49:02.416 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:49:02.418 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:50:05.385 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:50:05.388 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:51:08.333 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:51:08.335 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
**2022-09-08 16:52:11.325 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaState' changed from asleep to online**
2022-09-08 16:52:11.345 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaStateChangeTimestamp' changed from 2022-09-08T16:42:46.656414+0200 to 2022-09-08T16:52:11.331642+0200
2022-09-08 16:52:11.319 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:52:11.322 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:52:11.325 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is now awake, updating all data
2022-09-08 16:52:11.326 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:52:11.329 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:52:11.614 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle moved, resetting last location timestamp
2022-09-08 16:52:12.327 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: charge_state
2022-09-08 16:52:13.658 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaInsideTemperature' changed from 21.7 °C to 21.5 °C
2022-09-08 16:52:13.659 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaOutsideTemperature' changed from 21 °C to 20.5 °C
2022-09-08 16:52:13.328 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: climate_state
2022-09-08 16:52:14.330 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: gui_settings
2022-09-08 16:52:15.331 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: charge_state
2022-09-08 16:52:16.332 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: climate_state
2022-09-08 16:52:17.332 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: gui_settings
2022-09-08 16:52:18.334 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: mobile_enabled
2022-09-08 16:52:20.462 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:52:21.463 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:52:35.462 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:52:36.463 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:52:50.463 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:52:51.464 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:53:05.463 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:53:06.464 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:53:11.824 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaOutsideTemperature' changed from 20.5 °C to 21 °C
2022-09-08 16:53:11.489 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 16:53:11.491 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 16:53:11.494 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: charge_state
2022-09-08 16:53:11.494 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: climate_state
2022-09-08 16:53:12.495 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: gui_settings
2022-09-08 16:53:13.496 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: mobile_enabled
2022-09-08 16:53:20.464 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:53:21.465 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:53:35.464 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:53:36.465 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state
2022-09-08 16:53:50.464 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: drive_state
2022-09-08 16:53:51.465 [DEBUG] [internal.handler.TeslaAccountHandler] - Invoking: vehicle_state

In this second example, the state changes to asleep, but the binding appears do miss this (I marked the relevant lines again):

**2022-09-08 17:08:43.587 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaState' changed from online to asleep**
2022-09-08 17:08:43.592 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TeslaStateChangeTimestamp' changed from 2022-09-08T16:52:11.331642+0200 to 2022-09-08T17:08:43.589571+0200
2022-09-08 17:08:43.580 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:08:43.583 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:09:46.361 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:09:46.364 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:10:52.372 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:10:52.375 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:11:52.835 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:11:52.838 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:12:56.602 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:12:56.604 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:13:59.498 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:13:59.500 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:13:59.501 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle is inactive
2022-09-08 17:15:02.578 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:15:02.580 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:16:06.861 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:16:06.864 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:17:10.468 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:17:10.471 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:18:13.503 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:18:13.506 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:19:16.580 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:19:16.582 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:20:19.656 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:20:19.659 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:21:20.286 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:21:20.288 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:22:20.726 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:22:20.729 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:23:21.094 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:23:21.097 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:24:21.505 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:24:21.508 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:25:21.936 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:25:21.938 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:26:25.746 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:26:25.749 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:27:26.009 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:27:26.011 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:28:29.557 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:28:29.559 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:29:32.514 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:29:32.517 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:30:35.614 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:30:35.616 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:31:38.583 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:31:38.585 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:32:40.007 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:32:40.011 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:33:43.493 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:33:43.496 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
2022-09-08 17:34:43.700 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:34:43.703 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX
**2022-09-08 17:34:43.705 [DEBUG] [internal.handler.TeslaVehicleHandler] - Vehicle did not fall asleep within sleep period, checking again**
2022-09-08 17:35:44.160 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 200, OK
2022-09-08 17:35:44.162 [DEBUG] [internal.handler.TeslaVehicleHandler] - Querying the vehicle: VIN XXXXXXXXXXXXXXXXX

I don’t know what’s going on here. Combined with the unsolved token refresh problem I decided to disable the binding for now. If the binding was really this “confused” or broken, shouldn’t others/everyone have these problems?

You have to be careful about cause and effect, bearing in mind events very close together can get in the log “out of order”.
So, above, the query is timestamped earlier and naturally enough wakes the car up to answer the query?

Why would it make a query after this announcement?

I don’t know. Some unfinished business perhaps - we might imagine something like a configured value that cannot actually be read (wrong model or something) so the binding re-tries it from time to time as an error recovery, not taking ‘sleep’ into account.

1 Like

It always queries every minute. What it does is stops querying the detailed vehicle endpoint that wakes the car for 20 minutes, after 5 minutes of inactivity (this default is annoying imho but see below).
If you want to have more logging around what the binding is actually doing you can build the binding from my branch openhab2-addons/bundles/org.openhab.binding.tesla at tesla3.4 · billfor/openhab2-addons · GitHub. It will show additional debugging information regarding throttles and states. See [tesla] Options to control polling frequency and sleep (Model 3) by billfor · Pull Request #13337 · openhab/openhab-addons · GitHub for a description of what it does.

Hi guys,
maybe unrelated directly but I wanted to ask you as I see you’re using the binding… I’ve tested the binding on my Model Y but it seems I cannot do a “changes” - I can only read states of certain channels. Is that right and intended or something is not working on my end?
My idea is to start charging only when my solar inverter has enough power from the sun. There are two options - to trigger the powerwall or to trigger the tesla. Do you know if this may work?

Cheers,
K.

Hi,

I have just started to implement smart charging on my Tesla Model S. I’m building the algorithms in a NodeJS application utilizing the openhab REST API to “talk” with the car.

To start with, this was looking very promising, but after looking more into working with the binding, like hooking up some event listeners (EventSource) to ChargingState, ChargeLimit and SetChargingAmps, the binding seems very “unreliable”.

Sometimes it works (almost) as expected. When changing one of the above-mentioned properties via the REST API, the events are triggered – although with a substantial delay - and I get the new values back when requesting them.

When changing the same properties via the Tesla app, I’m not able to read the new values – and no events are triggered.

Does somebody have experience with, or knowledge about using this binding via the REST API?

Thanks!

Some additional info:
Just now, a change of ChargeLimit and SetChargingAmps from the app was working – with substantial delay.

A few minutes later, it stopped detecting changes done from the app again

1 Like

Hi, I would like to revert back to the original problem of this thread with having the binding online but no update coming through anymore. Based on the suggestion from @billfor to put in place an openhab instance in the cloud to rule out WAF I did two fresh installs with tesla plugin only:

  1. Openhab on windows laptop within my own network → same problem as with my raspberry → after latest 1day no update coming through anymore
  2. Openhab at a AWS debian instance → no problem with this setup. Binding keept reporting it’s values for over one week without any issues!
  3. Same exact Openhab installation from (1) at a friends home → working flawless for more than a week!

With this test I think it’s been proven that the problem must have something todo with the local network/ISP. Anyone got a clue what I can do/check? As I have no idea would be great to get a hint.

1 Like

Thank you for trying this, really interesting result! I’m currently using openHAB 3.4.0.M2 on docker on an Intel NUC on my local network. If this is indeed a network issue, I’m curious as to what causes this. Do you have an idea?

If you could define the rule I pasted above and show the graph of the amount of time spent in the various states, that might indicate a next step.
Failing that and depending on your ISP, releasing the DHCP WAN address on your router and getting a new one would be enough to give a new external IP address and hopefully make the WAF happy. Some providers may require the router/modem to be turned off for a while before offering a new address.

Yesterday, I was able to set things up. I did the item, rule and sitemap but not yet activated the tesla binding on my production system. While doing this I shut down all testing instances to make sure nothing interferes. This morning before I drove to work I enabled the tesla binding on my production system where I have this issue. Binding went online for the account without trouble but car thing needed two tries (configuration error) to get online. Then I took my drive to work and binding was still online at the time I arrived. Also the graph shows this as it was online at the beginning and went to sleep after arrival:
image
This evening I drove home but as one can see binding is dead again even though account and car thing has been online. Any advice appreciated.

Hi again,

the binding seems to work quite ok. The changes are visible in OpenHAB after a delay. Sometimes quite short delay, sometimes a long delay. Since the charging process is not very time critical, it should work according to the needs.

Does anyone know how the binding is ‘talking’ to the car? Polling intervals or event driven?

You folks that are having the token refresh issue, which model tesla do you have?

I have a 2022 Model Y.
I haven’t done any debug, just configured yesterday first time ( 3.4.0.M3)
After configuring it works fine for a few hours and then in the Tesla Account thing it reports as per below, if I get a new token it works fine again for a few hours.

Status:

OFFLINE

CONFIGURATION_ERROR

Failed to obtain access token for API.

Try downloading the latest snapshot and run it with DEBUG logging: https://ci.openhab.org/job/openHAB-Addons/859/artifact/bundles/org.openhab.binding.tesla/target/org.openhab.binding.tesla-3.4.0-SNAPSHOT.jar
This version will print out the access token lifetime and also the expiration.

After 8 hours, when the access token refresh fails, post all lines related to the authentication at the time of the failure, and also the lines from when you first initialized the binding:

Here is what they should look like at the beginning of initialization:

[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Initializing the Tesla account handler for bill
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Setting up an authenticated connection to the Tesla back-end
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Current authentication time 2022-10-16 13:25:53
[DEBUG] [hab.binding.tesla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
[DEBUG] [hab.binding.tesla.internal.handler.TeslaSSOHandler] - Access token expires in 28800 seconds at 2022-10-16 21:25:53
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Querying the vehicle: Response: 200: OK

Here is what they look like if the refresh is successful:

[DEBUG] [binding.tesla.internal.handler.TeslaVehicleHandler] - Vehicle state is asleep
[DEBUG] [binding.tesla.internal.handler.TeslaVehicleHandler] - Vehicle is asleep.
[DEBUG] [binding.tesla.internal.handler.TeslaVehicleHandler] - Querying the vehicle, response : 401, Unauthorized
[DEBUG] [binding.tesla.internal.handler.TeslaVehicleHandler] - The access token has expired, trying to get a new one.
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Current authentication time 2022-10-16 06:28:39
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Found a request token from 2022-10-15 22:28:36
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - Access token expiration time 2022-10-16 06:28:36
[DEBUG] [binding.tesla.internal.handler.TeslaAccountHandler] - The access token has expired
[DEBUG] [hab.binding.tesla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
[DEBUG] [hab.binding.tesla.internal.handler.TeslaSSOHandler] - Access token expires in 28800 seconds at 2022-10-16 14:28:40

This should hopefully pinpoint the problem, if it is actually the Tesla WAF or something else.

Hi @billfor,

I did as you asked, downloaded the latest snapshot and ran it. Here are the log snippets:

Initialization:

2022-10-24 11:39:51.499 [DEBUG] [internal.handler.TeslaAccountHandler] - Initializing the Tesla account handler for XXX
2022-10-24 11:39:51.500 [DEBUG] [internal.handler.TeslaAccountHandler] - Setting up an authenticated connection to the Tesla back-end
2022-10-24 11:39:51.501 [DEBUG] [internal.handler.TeslaAccountHandler] - Current authentication time 2022-10-24 11:39:51
2022-10-24 11:39:51.501 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
2022-10-24 11:39:51.962 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Access token expires in 28800 seconds at 2022-10-24 19:39:51
2022-10-24 11:39:52.367 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the vehicle: Response: 200: OK

(Failed) Refresh:

2022-10-24 19:39:52.801 [DEBUG] [internal.handler.TeslaAccountHandler] - The access token has expired, trying to get a new one.
2022-10-24 19:39:52.802 [DEBUG] [internal.handler.TeslaAccountHandler] - Current authentication time 2022-10-24 19:39:52
2022-10-24 19:39:52.802 [DEBUG] [internal.handler.TeslaAccountHandler] - Found a request token from 2022-10-24 11:39:51
2022-10-24 19:39:52.803 [DEBUG] [internal.handler.TeslaAccountHandler] - Access token expiration time 2022-10-24 19:39:51
2022-10-24 19:39:52.803 [DEBUG] [internal.handler.TeslaAccountHandler] - The access token has expired
2022-10-24 19:39:52.803 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Exchanging SSO refresh token for API access token
2022-10-24 19:39:52.814 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - An error occurred during refresh of SSO token: no response
2022-10-24 19:39:52.814 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - An exception occurred while invoking a HTTP request: 'java.io.EOFException: HttpConnectionOverHTTP@5f786cc4::DecryptedEndPoint@52c399ec{l=/192.168.XX.XX:44736,r=auth.tesla.com/92.123.29.76:443,OPEN,fill=-,flush=-,to=28800850/0}'
2022-10-24 19:39:52.816 [DEBUG] [internal.handler.TeslaAccountHandler] - An error occurred while communicating with the vehicle during request drive_state: 401: Unauthorized

I don’t understand why the binding can retrieve an access token initially (and after each openhab restart) but not after 8 hours of running.

One thing you could try doing is to try to restart the binding manually right before the 8 hour mark and see if you can get an access token.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.