Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing sleep state, long wake times and errors in log with MCU2 updated cars #3084

Open
1 task done
markusdd opened this issue Jan 22, 2023 · 198 comments · May be fixed by #4453
Open
1 task done

Missing sleep state, long wake times and errors in log with MCU2 updated cars #3084

markusdd opened this issue Jan 22, 2023 · 198 comments · May be fixed by #4453
Labels
area:tesla api Related to the Tesla API

Comments

@markusdd
Copy link
Contributor

markusdd commented Jan 22, 2023

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The car only switches between online and offline state, sleep does never occur.
Also, the log is littered with weird API errors and the wakeup times of the car are far too frequent and long, leading to bad phantom drain.
Also raised this in the discussion area: #3083

Expected Behavior

the car goes to sleep (not offline), there are no API query errors in the log and the car actually sleeps when it is not being used or charged

Steps To Reproduce

if only I knew, but I can give my config:

  • Streaming API is enabled
  • apart fromt his weird behavior everything else works, drives etc are all recorded fine
  • car works
  • this is an 85D Model S with MCU2 upgrade, so no MCU1 energy save settings required/possible
  • no other services are registered with my account except Teslamate

In the current example the below log output belongs to the last offline/online phase, error prints start happeneing at around the red arrow marker:
grafik

Relevant log output

see screen below

Screenshots

grafik

ok....and now after a long wake period we are suddenly offline....that is weird.
grafik

Additional data

No response

Type of installation

Manual

Version

v1.27.2

@markusdd markusdd changed the title Missing sleep state Missing sleep state, long wake times and errors in log Jan 22, 2023
@woutersmit
Copy link

fyi HTTP 408's are just a way for the api to communicate the verhicle IS in standby. After which you'd send a 'wake_up' api-call.

But, I'm also seeing increased drain caused by verhicle standby. Will try to rollback a version and see if that solves it.

@micves
Copy link
Contributor

micves commented Mar 17, 2023

I'm seeing the same pattern with my Model S 2017 upgraded to MCU2 (version 2023.2.12)
I only just started using teslamate, so I don't know how it looked before MCU2.
Streaming API is enabled.

When teslamate is running I'm getting 54 minutes of offline and 19 minutes of online according to grafana.

If I turn off teslamate and poll the API (using the command from this comment: #1288 (reply in thread) )
it only wakes up for about 3-4 minutes.

It seems that teslamate is keeping it awake for longer than necessary.

teslamate_1 | 2023-03-17 14:01:38.024 car_id=1 [info] Start / :online
teslamate_1 | 2023-03-17 14:01:38.075 car_id=1 [info] Connecting ...
teslamate_1 | 2023-03-17 14:04:42.039 car_id=1 [info] Suspending logging

So the question might be:
What is happening behind [info] Start / :online and [info] Connecting ... that is extending the wake time?

@adriankumpf do you remember off the top of your head? :) Is it getting vehicle_data or starting the streaming API ?

@markusdd
Copy link
Contributor Author

markusdd commented Mar 17, 2023

I confirm. I have run similar experiments and is definetly teslamate keeping the car awake and creating this pattern. The phantom drain (and hence cost) of this is pretty substantial. But I would hate having to turn of teslamte. It would be good to get some support on debugging this.

@micves
Copy link
Contributor

micves commented Mar 17, 2023

Still having teslamate off I did a poll on vehicle_data when the car came online. This extended the time :(

And the normal state response (https://owner-api.teslamotors.com/api/1/vehicles/:id) doesn't contain any info if its a real online or just a i'm-just-checking-in online

Hopefully the streaming API can connect for more info and not extend the wake time... I'm not really into that yet, so hopefully someone else can enlighten us :)

@micves
Copy link
Contributor

micves commented Mar 28, 2023

I have done some tests using https://github.com/tdorssers/TeslaPy

My code is here if somebody would like to try it out:

#!/usr/bin/env python
import teslapy
from datetime import datetime
import time
import logging

state=None
code_verifier=None
#logging.basicConfig(level=logging.DEBUG)

# First stage
tesla = teslapy.Tesla('mymail@mail.com, retry=2, timeout=15)
if not tesla.authorized:
    state = tesla.new_state()
    code_verifier = tesla.new_code_verifier()
    print('Use browser to login. Page Not Found will be shown at success.')
    print('Open: ' + tesla.authorization_url(state=state, code_verifier=code_verifier))
    tesla.close()
    # Second stage
    tesla = teslapy.Tesla('[email protected]', state=state, code_verifier=code_verifier)
    if not tesla.authorized:
        tesla.fetch_token(authorization_response=input('Enter URL after authentication: '))

vehicles = tesla.vehicle_list()
vehicle = vehicles[0]
current_state = vehicle.get_vehicle_summary()['state']
t_start = datetime.now()
print(str(datetime.now()) + ': ' + current_state)
last_state = current_state

#stream callback
def stream_cb(mydict):
    print(mydict)

time.sleep(10)
exCount = 0
try:
    while True:
        try:
            current_state = vehicle.get_vehicle_summary()['state']
            exCount = 0
        except Exception:
            exCount = exCount + 1 
            print(str(datetime.now()) + ": Exception "+ str(exCount) +", sleep 90")
            time.sleep(90)
        if last_state != current_state:
            t_end = datetime.now()
            print(str(datetime.now()) + ': ' + '{:>7}'.format(last_state) + ' for {:6.2f}'.format((t_end - t_start).total_seconds() / 60) + ' min, new state: ' + current_state)
            t_start = datetime.now()

            # start the stream
            vehicle.stream(stream_cb) # retry=12 seems to get more samples, but also locks up and no new states are detected

            # print(vehicle.get_latest_vehicle_data())
            # requests.exceptions.HTTPError: 404 Client Error: Not Found for url:
            # #https://owner-api.teslamotors.com/api/1/vehicles/{id}/latest_vehicle_data 
            # even in online state

        last_state = current_state
        time.sleep(10)
except KeyboardInterrupt:
    print('closing')
    tesla.close()

First test is with Teslamate off:

I start a stream every time there is a change in state:

2023-03-26 13:19:52.462120: offline
2023-03-26 14:07:37.737771: offline for  47.75 min, new state: online
{'soc': 64, 'elevation': 31, 'est_lat': xx.358406, 'power': None, 'est_range': 147, 'timestamp': 1679832428944, 'heading': 22, 'odometer': 86385.3, 'range': 171, 'est_lng': yy.571832, 'est_heading': 22, 'speed': None, 'shift_state': None}
2023-03-26 14:10:20.099877:  online for   2.71 min, new state: offline
2023-03-26 15:08:37.788812: offline for  58.29 min, new state: online
{'soc': 64, 'elevation': 31, 'est_lat': xx.358406, 'power': None, 'est_range': 147, 'timestamp': 1679836088398, 'heading': 22, 'odometer': 86385.3, 'range': 171, 'est_lng': yy.571832, 'est_heading': 22, 'speed': None, 'shift_state': None}
2023-03-26 15:11:20.035421:  online for   2.70 min, new state: offline

At this point, when the car is in offline, I open the Tesla app and thereby wake the car for real:

2023-03-26 15:47:01.532903: offline for  35.69 min, new state: online
{'soc': 64, 'elevation': 31, 'est_lat': xx.358406, 'power': 0, 'est_range': 146, 'timestamp': 1679838391939, 'heading': 22, 'odometer': 86385.3, 'range': 170, 'est_lng': yy.571832, 'est_heading': 22, 'speed': None, 'shift_state': None}

Notice the power says 0 instead of None.

I then tried with teslamate on, teslapy poll 10 sec and stream retry of 12 (hope to catch a None before teslamate poll vehicle_data)

2023-03-27 20:19:03.458722: offline
2023-03-27 20:35:03.836941: offline for  16.01 min, new state: online
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': None, 'est_range': 146, 'timestamp': 1679942102760, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': None, 'est_range': 146, 'timestamp': 1679942113982, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 146, 'timestamp': 1679942115733, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942116232, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942138041, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942149163, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942160357, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942206898, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
{'soc': 68, 'elevation': 15, 'est_lat': xx.358393, 'power': 0, 'est_range': 145, 'timestamp': 1679942218158, 'heading': 23, 'odometer': 86444.4, 'range': 179, 'est_lng': yy.571729, 'est_heading': 22, 'speed': None, 'shift_state': None}
2023-03-27 20:50:20.295447:  online for  15.27 min, new state: offline

It seems that power is None when the online is the 'fake' online.
power is 0 after teslamate requests a vehicle_data and wakes the car for real.
(None is a python-thing, but I would guess Elixir gets nil, null or something similar)

Maybe this could be used in Teslamate for handling this issue?

@markusdd
Copy link
Contributor Author

That is a VERY interesting observvation and maybe the key to finally get rid of this phantom drain.

@adriankumpf what do you say? I know very little about Elixir, might this be useful?

@sb1089
Copy link

sb1089 commented Apr 13, 2023

I have the same issues awake/sleep issues with my Model S with upgraded MCU and I think it applies to more people indeed (#2556).
I like your finding. Hopefully someone can implement this check into Teslamate.
Currently I turn off Teslamate every night to preserve the battery drain.

@markusdd
Copy link
Contributor Author

As a call to action here: I would be willing to look into this but my experience with Elixir is absolutely zero, as well as with this code base.

@adriankumpf do you have any time to address this based on what has been posted above or can you give at least a hint to the part of the code base where changes would likely need to be made?

I do run a manual install so doing local changes and recompile would be quite easy to do for me.

@markusdd
Copy link
Contributor Author

@micves and @sb1089 as Adrian is unfortunately not responding at all for weeks now I tried to have a look myself
and here seems to be the region where basically Teslamate falls for the 'fake' online state https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L700

It then proceeds to poll the vehicle_data API
image
und this directly correlates with this loooong online state that furthers battery drain.
image

So at this point we need to somehow recognize it is a fake online state and let the vehicle sleep.

@micves
Copy link
Contributor

micves commented Apr 27, 2023

I also started looking into it myself last week. Never got around to write about it, but I'll try to describe my findings so far.

I also started with the log 'Start / :online' but couldn't really figure out how everything was working. Elixir is quite different to my other known languages :)

I got a development environment set up and added some more Log.info around the code. Old school debug, but it works. At some point I'll write my steps for that here: #1903

At 'Start / :online' it is too late to check if it is a fake online. The api call to vehicle_data has already been executed and woken the car up.

When the car is offline this regularly gets the state:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L1103

schedule_fetch ends up calling:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L1189

which in case of online (also fake online) calls:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L1217

that end up in here:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/tesla_api/vehicle.ex#L54
(vehicle_data is the one waking the car completely)

I'm guessing 'Start / :online' is an event based on the fact that the state is online.
I think this is the one setting it to online in the result_handler of the fetch:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L312

The stream is started in the same place as 'Start / :online'. This is a issue, that it is started so late, if we want to see if the power is nil or 0 to determine if its a fake or a real online.
And we need that already in the fetch function.

This is kind of where I got stuck for now. And I'm a little scared of Elixir :D

@markusdd
Copy link
Contributor Author

I can relate. I would not even say that I am completely devoid of understanding how functional programming works but Elixir is just somethign else. The syntax is...special. To be kind.

I can follow what you are saying and agree with it. we probably somehow need to pick apart that last statement and make sure whenever power shows something similar to a NULL value we just act as if the car is asleep.

@markusdd
Copy link
Contributor Author

and I just try it again: @adriankumpf if you don't have the time that is ok, but can you at least give us SOME hint where we need to look to apply a fix for this? I think we are pretty close here but Elixir makes it really hard. I have real issues understanding the control flow of this code :(

@markusdd
Copy link
Contributor Author

markusdd commented Apr 28, 2023

Ok I now also put in some logging in my installation and it is a hard one to catch:
grafik

Teslamate correctly suspends logging after some time after a drive and goes into stream only mode.
Then at some point weird error messages come as the car transistions into offline, which seems to not be gracefully handled. (but at least it goes offline)
But about an hour later an unsolited API call happens, waking up the car.

As you can see there are no detailed logs, so I still have not found the location in the code where this call happens and first and foremost: WHY.

This is frustrating...

@micves
Copy link
Contributor

micves commented Apr 28, 2023

I think the errors are not handled gracefully because its a rare behavior that only MCU2 upgraded cars do.
All other cars are in either asleep or online.

I have talked to a Tesla service center that says it normal behavior for a MCU2 upgraded car to be offline ~1hour and online for 2-3 minutes. Also with no 3rd party access.
It is the car waking it self up to check sub-systems. When it does this it apparently shows itself as online in the API.

So that is something we cannot control. But we can fix the extension of online and going from subsystem online to real online.

I think your API call starts at the line i also wrote in my last post.
If you put in a log here after the 'do' you will get the initiator:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L1101-L1104

This however happens every 30 seconds so it will flood the log.

So every 30 seconds you get into the fetch_with_unreachable_assumption:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L1215-L1219

I'm guessing your log is just before the 'call(deps.api, :get_vehicle_with_state, [id])'

But look at the line above: 'with {:ok, %Vehicle{state: "online"}} <- call(deps.api, :get_vehicle, [id]) do'

As I see that line it calls the get_vehicle function that gets the state of the car without waking the car.
If the car is online (in our case to check sub-systems) it will call the get_vehicle_with_state

@markusdd
Copy link
Contributor Author

markusdd commented Apr 28, 2023

Good point.

Still, I am unsure how to distinguish between 'real online' and 'fake online'.
Below you see a logging which I put in all 5 'offline/asleep' handle_event functions.
When the car is offline, it constantly uses the first function and the saved data is power: nil, shift_state unknown.
It then suddenly uses the 5th function, where power becomes 0 and shift_state nil, afterwards the wakeup happens.
But this is also the case in regular online state...

Apr 28 15:20:40 tesla teslamate[171598]: 2023-04-28 15:20:40.552 [info] In 1. asleep/offline handle_event function in state: offline and power: %TeslaMate.Vehicles.Vehicle.Data{
Apr 28 15:20:40 tesla teslamate[171598]:   car: %TeslaMate.Log.Car{
Apr 28 15:20:40 tesla teslamate[171598]:     __meta__: #Ecto.Schema.Metadata<:loaded, "cars">,
Apr 28 15:20:40 tesla teslamate[171598]:     charging_processes: #Ecto.Association.NotLoaded<association :charging_processes is not loaded>,
Apr 28 15:20:40 tesla teslamate[171598]:     drives: #Ecto.Association.NotLoaded<association :drives is not loaded>,
Apr 28 15:20:40 tesla teslamate[171598]:     efficiency: 0.185,
Apr 28 15:20:40 tesla teslamate[171598]:     eid: 1492932437245351,
Apr 28 15:20:40 tesla teslamate[171598]:     exterior_color: "SteelGrey",
Apr 28 15:20:40 tesla teslamate[171598]:     id: 1,
Apr 28 15:20:40 tesla teslamate[171598]:     inserted_at: ~N[2020-01-12 11:48:53],
Apr 28 15:20:40 tesla teslamate[171598]:     marketing_name: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     model: "S",
Apr 28 15:20:40 tesla teslamate[171598]:     name: "Hyperion",
Apr 28 15:20:40 tesla teslamate[171598]:     positions: #Ecto.Association.NotLoaded<association :positions is not loaded>,
Apr 28 15:20:40 tesla teslamate[171598]:     settings: %TeslaMate.Settings.CarSettings{
Apr 28 15:20:40 tesla teslamate[171598]:       __meta__: #Ecto.Schema.Metadata<:loaded, "car_settings">,
Apr 28 15:20:40 tesla teslamate[171598]:       car: #Ecto.Association.NotLoaded<association :car is not loaded>,
Apr 28 15:20:40 tesla teslamate[171598]:       free_supercharging: true,
Apr 28 15:20:40 tesla teslamate[171598]:       id: 1,
Apr 28 15:20:40 tesla teslamate[171598]:       req_not_unlocked: true,
Apr 28 15:20:40 tesla teslamate[171598]:       suspend_after_idle_min: 15,
Apr 28 15:20:40 tesla teslamate[171598]:       suspend_min: 21,
Apr 28 15:20:40 tesla teslamate[171598]:       use_streaming_api: true
Apr 28 15:20:40 tesla teslamate[171598]:     },
Apr 28 15:20:40 tesla teslamate[171598]:     settings_id: 1,
Apr 28 15:20:40 tesla teslamate[171598]:     spoiler_type: "None",
Apr 28 15:20:40 tesla teslamate[171598]:     trim_badging: "85D",
Apr 28 15:20:40 tesla teslamate[171598]:     updated_at: ~N[2023-02-16 18:49:49],
Apr 28 15:20:40 tesla teslamate[171598]:     vid: 252208806,
Apr 28 15:20:40 tesla teslamate[171598]:     vin: "xxx",
Apr 28 15:20:40 tesla teslamate[171598]:     wheel_type: "Turbine19"
Apr 28 15:20:40 tesla teslamate[171598]:   },
Apr 28 15:20:40 tesla teslamate[171598]:   deps: %{
Apr 28 15:20:40 tesla teslamate[171598]:     api: TeslaMate.Api,
Apr 28 15:20:40 tesla teslamate[171598]:     locations: TeslaMate.Locations,
Apr 28 15:20:40 tesla teslamate[171598]:     log: TeslaMate.Log,
Apr 28 15:20:40 tesla teslamate[171598]:     pubsub: Phoenix.PubSub,
Apr 28 15:20:40 tesla teslamate[171598]:     settings: TeslaMate.Settings,
Apr 28 15:20:40 tesla teslamate[171598]:     vehicles: TeslaMate.Vehicles
Apr 28 15:20:40 tesla teslamate[171598]:   },
Apr 28 15:20:40 tesla teslamate[171598]:   elevation: nil,
Apr 28 15:20:40 tesla teslamate[171598]:   geofence: nil,
Apr 28 15:20:40 tesla teslamate[171598]:   import?: false,
Apr 28 15:20:40 tesla teslamate[171598]:   last_response: %TeslaApi.Vehicle{
Apr 28 15:20:40 tesla teslamate[171598]:     api_version: 54,
Apr 28 15:20:40 tesla teslamate[171598]:     backseat_token: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     backseat_token_updated_at: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     calendar_enabled: true,
Apr 28 15:20:40 tesla teslamate[171598]:     charge_state: %TeslaApi.Vehicle.State.Charge{
Apr 28 15:20:40 tesla teslamate[171598]:       charge_port_latch: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       scheduled_charging_pending: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_current_request_max: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fast_charger_type: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_limit_soc_min: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_to_max_range: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       time_to_full_charge: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_miles_added_rated: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_miles_added_ideal: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fast_charger_present: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charger_phases: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       scheduled_charging_start_time: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       not_enough_power_to_heat: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_limit_soc_std: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_port_cold_weather_mode: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       managed_charging_start_time: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charger_actual_current: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       timestamp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       ideal_battery_range: 159.53,
Apr 28 15:20:40 tesla teslamate[171598]:       charger_power: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       battery_level: 65,
Apr 28 15:20:40 tesla teslamate[171598]:       max_range_charge_counter: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_current_request: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       trip_charging: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_port_door_open: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       conn_charge_cable: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fast_charger_brand: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_energy_added: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       charging_state: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       battery_heater_on: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charger_pilot_current: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_rate: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       battery_range: 199.41,
Apr 28 15:20:40 tesla teslamate[171598]:       est_battery_range: 136.61,
Apr 28 15:20:40 tesla teslamate[171598]:       managed_charging_active: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_limit_soc: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       usable_battery_level: 65,
Apr 28 15:20:40 tesla teslamate[171598]:       charger_voltage: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       charge_limit_soc_max: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       ...
Apr 28 15:20:40 tesla teslamate[171598]:     },
Apr 28 15:20:40 tesla teslamate[171598]:     climate_state: %TeslaApi.Vehicle.State.Climate{
Apr 28 15:20:40 tesla teslamate[171598]:       battery_heater: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       battery_heater_no_power: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       climate_keeper_mode: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       defrost_mode: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       driver_temp_setting: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fan_status: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       inside_temp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       is_auto_conditioning_on: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       is_climate_on: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       is_front_defroster_on: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       is_preconditioning: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       is_rear_defroster_on: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       left_temp_direction: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       max_avail_temp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       min_avail_temp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       outside_temp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       passenger_temp_setting: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       remote_heater_control_enabled: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       right_temp_direction: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_left: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_rear_center: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_rear_left: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_rear_left_back: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_rear_right: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_rear_right_back: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       seat_heater_right: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       side_mirror_heaters: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       smart_preconditioning: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       steering_wheel_heater: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       timestamp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       wiper_blade_heater: nil
Apr 28 15:20:40 tesla teslamate[171598]:     },
Apr 28 15:20:40 tesla teslamate[171598]:     color: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     display_name: "Hyperion",
Apr 28 15:20:40 tesla teslamate[171598]:     drive_state: %TeslaApi.Vehicle.State.Drive{
Apr 28 15:20:40 tesla teslamate[171598]:       gps_as_of: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       heading: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       latitude: #Decimal<51.057609>,
Apr 28 15:20:40 tesla teslamate[171598]:       longitude: #Decimal<13.772231>,
Apr 28 15:20:40 tesla teslamate[171598]:       native_latitude: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       native_location_supported: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       native_longitude: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       native_type: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       power: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       shift_state: :unknown,
Apr 28 15:20:40 tesla teslamate[171598]:       speed: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       timestamp: nil
Apr 28 15:20:40 tesla teslamate[171598]:     },
Apr 28 15:20:40 tesla teslamate[171598]:     gui_settings: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     id: 1492932437245351,
Apr 28 15:20:40 tesla teslamate[171598]:     in_service: false,
Apr 28 15:20:40 tesla teslamate[171598]:     option_codes: [""],
Apr 28 15:20:40 tesla teslamate[171598]:     state: "offline",
Apr 28 15:20:40 tesla teslamate[171598]:     tokens: ["xxx", "xxx"],
Apr 28 15:20:40 tesla teslamate[171598]:     vehicle_config: nil,
Apr 28 15:20:40 tesla teslamate[171598]:     vehicle_id: 252208806,
Apr 28 15:20:40 tesla teslamate[171598]:     vehicle_state: %TeslaApi.Vehicle.State.VehicleState{
Apr 28 15:20:40 tesla teslamate[171598]:       is_user_present: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       valet_mode: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       tpms_pressure_fl: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       api_version: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       valet_pin_needed: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fd_window: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       last_autopark_error: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       rp_window: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       sentry_mode: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       car_version: "2023.6.8 ca519fc096f3",
Apr 28 15:20:40 tesla teslamate[171598]:       pf: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       summon_standby_mode_enabled: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       remote_start_enabled: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       remote_start: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       autopark_state_v3: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       dr: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       homelink_nearby: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       calendar_supported: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       timestamp: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       parsed_calendar_supported: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       notifications_supported: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       software_update: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       ft: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       odometer: 79548.755613,
Apr 28 15:20:40 tesla teslamate[171598]:       autopark_style: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       fp_window: nil,
Apr 28 15:20:40 tesla teslamate[171598]:       ...
Apr 28 15:20:40 tesla teslamate[171598]:     },
Apr 28 15:20:40 tesla teslamate[171598]:     vin: "xxx"
Apr 28 15:20:40 tesla teslamate[171598]:   },
Apr 28 15:20:40 tesla teslamate[171598]:   last_state_change: ~U[2023-04-28 12:23:08.129649Z],
Apr 28 15:20:40 tesla teslamate[171598]:   last_used: ~U[2023-04-28 12:42:21.858508Z],
Apr 28 15:20:40 tesla teslamate[171598]:   stream_pid: nil,
Apr 28 15:20:40 tesla teslamate[171598]:   task: nil
Apr 28 15:20:40 tesla teslamate[171598]: }
Apr 28 15:21:10 tesla teslamate[171598]: 2023-04-28 15:21:10.653 [info] In fetch_with_unreachable_assumption
Apr 28 15:21:12 tesla teslamate[171598]: 2023-04-28 15:21:12.250 [info] In 5. asleep/offline handle_event function in state: offline and power: %TeslaMate.Vehicles.Vehicle.Data{
Apr 28 15:21:12 tesla teslamate[171598]:   car: %TeslaMate.Log.Car{
Apr 28 15:21:12 tesla teslamate[171598]:     __meta__: #Ecto.Schema.Metadata<:loaded, "cars">,
Apr 28 15:21:12 tesla teslamate[171598]:     charging_processes: #Ecto.Association.NotLoaded<association :charging_processes is not loaded>,
Apr 28 15:21:12 tesla teslamate[171598]:     drives: #Ecto.Association.NotLoaded<association :drives is not loaded>,
Apr 28 15:21:12 tesla teslamate[171598]:     efficiency: 0.185,
Apr 28 15:21:12 tesla teslamate[171598]:     eid: 1492932437245351,
Apr 28 15:21:12 tesla teslamate[171598]:     exterior_color: "SteelGrey",
Apr 28 15:21:12 tesla teslamate[171598]:     id: 1,
Apr 28 15:21:12 tesla teslamate[171598]:     inserted_at: ~N[2020-01-12 11:48:53],
Apr 28 15:21:12 tesla teslamate[171598]:     marketing_name: nil,
Apr 28 15:21:12 tesla teslamate[171598]:     model: "S",
Apr 28 15:21:12 tesla teslamate[171598]:     name: "Hyperion",
Apr 28 15:21:12 tesla teslamate[171598]:     positions: #Ecto.Association.NotLoaded<association :positions is not loaded>,
Apr 28 15:21:12 tesla teslamate[171598]:     settings: %TeslaMate.Settings.CarSettings{
Apr 28 15:21:12 tesla teslamate[171598]:       __meta__: #Ecto.Schema.Metadata<:loaded, "car_settings">,
Apr 28 15:21:12 tesla teslamate[171598]:       car: #Ecto.Association.NotLoaded<association :car is not loaded>,
Apr 28 15:21:12 tesla teslamate[171598]:       free_supercharging: true,
Apr 28 15:21:12 tesla teslamate[171598]:       id: 1,
Apr 28 15:21:12 tesla teslamate[171598]:       req_not_unlocked: true,
Apr 28 15:21:12 tesla teslamate[171598]:       suspend_after_idle_min: 15,
Apr 28 15:21:12 tesla teslamate[171598]:       suspend_min: 21,
Apr 28 15:21:12 tesla teslamate[171598]:       use_streaming_api: true
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     settings_id: 1,
Apr 28 15:21:12 tesla teslamate[171598]:     spoiler_type: "None",
Apr 28 15:21:12 tesla teslamate[171598]:     trim_badging: "85D",
Apr 28 15:21:12 tesla teslamate[171598]:     updated_at: ~N[2023-02-16 18:49:49],
Apr 28 15:21:12 tesla teslamate[171598]:     vid: 252208806,
Apr 28 15:21:12 tesla teslamate[171598]:     vin: "xxx",
Apr 28 15:21:12 tesla teslamate[171598]:     wheel_type: "Turbine19"
Apr 28 15:21:12 tesla teslamate[171598]:   },
Apr 28 15:21:12 tesla teslamate[171598]:   deps: %{
Apr 28 15:21:12 tesla teslamate[171598]:     api: TeslaMate.Api,
Apr 28 15:21:12 tesla teslamate[171598]:     locations: TeslaMate.Locations,
Apr 28 15:21:12 tesla teslamate[171598]:     log: TeslaMate.Log,
Apr 28 15:21:12 tesla teslamate[171598]:     pubsub: Phoenix.PubSub,
Apr 28 15:21:12 tesla teslamate[171598]:     settings: TeslaMate.Settings,
Apr 28 15:21:12 tesla teslamate[171598]:     vehicles: TeslaMate.Vehicles
Apr 28 15:21:12 tesla teslamate[171598]:   },
Apr 28 15:21:12 tesla teslamate[171598]:   elevation: nil,
Apr 28 15:21:12 tesla teslamate[171598]:   geofence: nil,
Apr 28 15:21:12 tesla teslamate[171598]:   import?: false,
Apr 28 15:21:12 tesla teslamate[171598]:   last_response: %TeslaApi.Vehicle{
Apr 28 15:21:12 tesla teslamate[171598]:     api_version: 54,
Apr 28 15:21:12 tesla teslamate[171598]:     backseat_token: nil,
Apr 28 15:21:12 tesla teslamate[171598]:     backseat_token_updated_at: nil,
Apr 28 15:21:12 tesla teslamate[171598]:     calendar_enabled: true,
Apr 28 15:21:12 tesla teslamate[171598]:     charge_state: %TeslaApi.Vehicle.State.Charge{
Apr 28 15:21:12 tesla teslamate[171598]:       charge_port_latch: "<invalid>",
Apr 28 15:21:12 tesla teslamate[171598]:       scheduled_charging_pending: false,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_current_request_max: 16,
Apr 28 15:21:12 tesla teslamate[171598]:       fast_charger_type: "<invalid>",
Apr 28 15:21:12 tesla teslamate[171598]:       charge_limit_soc_min: 50,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_to_max_range: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       time_to_full_charge: 0.0,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_miles_added_rated: 213.5,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_miles_added_ideal: 171.0,
Apr 28 15:21:12 tesla teslamate[171598]:       fast_charger_present: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charger_phases: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       scheduled_charging_start_time: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       not_enough_power_to_heat: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_limit_soc_std: 90,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_port_cold_weather_mode: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       managed_charging_start_time: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charger_actual_current: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       timestamp: 1682688072094,
Apr 28 15:21:12 tesla teslamate[171598]:       ideal_battery_range: 159.53,
Apr 28 15:21:12 tesla teslamate[171598]:       charger_power: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       battery_level: 65,
Apr 28 15:21:12 tesla teslamate[171598]:       max_range_charge_counter: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_current_request: 16,
Apr 28 15:21:12 tesla teslamate[171598]:       trip_charging: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_port_door_open: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       conn_charge_cable: "<invalid>",
Apr 28 15:21:12 tesla teslamate[171598]:       fast_charger_brand: "<invalid>",
Apr 28 15:21:12 tesla teslamate[171598]:       charge_energy_added: 50.91,
Apr 28 15:21:12 tesla teslamate[171598]:       charging_state: "Disconnected",
Apr 28 15:21:12 tesla teslamate[171598]:       battery_heater_on: false,
Apr 28 15:21:12 tesla teslamate[171598]:       charger_pilot_current: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_rate: 0.0,
Apr 28 15:21:12 tesla teslamate[171598]:       battery_range: 199.41,
Apr 28 15:21:12 tesla teslamate[171598]:       est_battery_range: 136.61,
Apr 28 15:21:12 tesla teslamate[171598]:       managed_charging_active: false,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_limit_soc: 87,
Apr 28 15:21:12 tesla teslamate[171598]:       usable_battery_level: 65,
Apr 28 15:21:12 tesla teslamate[171598]:       charger_voltage: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       charge_limit_soc_max: 100,
Apr 28 15:21:12 tesla teslamate[171598]:       ...
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     climate_state: %TeslaApi.Vehicle.State.Climate{
Apr 28 15:21:12 tesla teslamate[171598]:       battery_heater: false,
Apr 28 15:21:12 tesla teslamate[171598]:       battery_heater_no_power: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       climate_keeper_mode: "off",
Apr 28 15:21:12 tesla teslamate[171598]:       defrost_mode: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       driver_temp_setting: 23.0,
Apr 28 15:21:12 tesla teslamate[171598]:       fan_status: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       inside_temp: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       is_auto_conditioning_on: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       is_climate_on: false,
Apr 28 15:21:12 tesla teslamate[171598]:       is_front_defroster_on: false,
Apr 28 15:21:12 tesla teslamate[171598]:       is_preconditioning: false,
Apr 28 15:21:12 tesla teslamate[171598]:       is_rear_defroster_on: false,
Apr 28 15:21:12 tesla teslamate[171598]:       left_temp_direction: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       max_avail_temp: 28.0,
Apr 28 15:21:12 tesla teslamate[171598]:       min_avail_temp: 15.0,
Apr 28 15:21:12 tesla teslamate[171598]:       outside_temp: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       passenger_temp_setting: 23.0,
Apr 28 15:21:12 tesla teslamate[171598]:       remote_heater_control_enabled: false,
Apr 28 15:21:12 tesla teslamate[171598]:       right_temp_direction: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_left: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_rear_center: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_rear_left: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_rear_left_back: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_rear_right: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_rear_right_back: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       seat_heater_right: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       side_mirror_heaters: false,
Apr 28 15:21:12 tesla teslamate[171598]:       smart_preconditioning: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       steering_wheel_heater: false,
Apr 28 15:21:12 tesla teslamate[171598]:       timestamp: 1682688072094,
Apr 28 15:21:12 tesla teslamate[171598]:       wiper_blade_heater: false
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     color: nil,
Apr 28 15:21:12 tesla teslamate[171598]:     display_name: "Hyperion",
Apr 28 15:21:12 tesla teslamate[171598]:     drive_state: %TeslaApi.Vehicle.State.Drive{
Apr 28 15:21:12 tesla teslamate[171598]:       gps_as_of: 1682688070,
Apr 28 15:21:12 tesla teslamate[171598]:       heading: 71,
Apr 28 15:21:12 tesla teslamate[171598]:       latitude: 51.057609,
Apr 28 15:21:12 tesla teslamate[171598]:       longitude: 13.772231,
Apr 28 15:21:12 tesla teslamate[171598]:       native_latitude: 51.057609,
Apr 28 15:21:12 tesla teslamate[171598]:       native_location_supported: 1,
Apr 28 15:21:12 tesla teslamate[171598]:       native_longitude: 13.772231,
Apr 28 15:21:12 tesla teslamate[171598]:       native_type: "wgs",
Apr 28 15:21:12 tesla teslamate[171598]:       power: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       shift_state: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       speed: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       timestamp: 1682688072094
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     gui_settings: nil,
Apr 28 15:21:12 tesla teslamate[171598]:     id: 1492932437245351,
Apr 28 15:21:12 tesla teslamate[171598]:     in_service: false,
Apr 28 15:21:12 tesla teslamate[171598]:     option_codes: [""],
Apr 28 15:21:12 tesla teslamate[171598]:     state: "online",
Apr 28 15:21:12 tesla teslamate[171598]:     tokens: ["xxx", "xxx"],
Apr 28 15:21:12 tesla teslamate[171598]:     vehicle_config: %TeslaApi.Vehicle.State.VehicleConfig{
Apr 28 15:21:12 tesla teslamate[171598]:       can_accept_navigation_requests: true,
Apr 28 15:21:12 tesla teslamate[171598]:       can_actuate_trunks: true,
Apr 28 15:21:12 tesla teslamate[171598]:       car_special_type: "base",
Apr 28 15:21:12 tesla teslamate[171598]:       car_type: "models",
Apr 28 15:21:12 tesla teslamate[171598]:       charge_port_type: "EU",
Apr 28 15:21:12 tesla teslamate[171598]:       eu_vehicle: true,
Apr 28 15:21:12 tesla teslamate[171598]:       exterior_color: "SteelGrey",
Apr 28 15:21:12 tesla teslamate[171598]:       has_air_suspension: true,
Apr 28 15:21:12 tesla teslamate[171598]:       has_ludicrous_mode: false,
Apr 28 15:21:12 tesla teslamate[171598]:       key_version: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       motorized_charge_port: false,
Apr 28 15:21:12 tesla teslamate[171598]:       perf_config: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       plg: true,
Apr 28 15:21:12 tesla teslamate[171598]:       rear_seat_heaters: 1,
Apr 28 15:21:12 tesla teslamate[171598]:       rear_seat_type: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       rhd: false,
Apr 28 15:21:12 tesla teslamate[171598]:       roof_color: "None",
Apr 28 15:21:12 tesla teslamate[171598]:       seat_type: 1,
Apr 28 15:21:12 tesla teslamate[171598]:       spoiler_type: "None",
Apr 28 15:21:12 tesla teslamate[171598]:       sun_roof_installed: 1,
Apr 28 15:21:12 tesla teslamate[171598]:       third_row_seats: "None",
Apr 28 15:21:12 tesla teslamate[171598]:       timestamp: 1682688072094,
Apr 28 15:21:12 tesla teslamate[171598]:       trim_badging: "85d",
Apr 28 15:21:12 tesla teslamate[171598]:       use_range_badging: false,
Apr 28 15:21:12 tesla teslamate[171598]:       wheel_type: "Turbine19"
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     vehicle_id: 252208806,
Apr 28 15:21:12 tesla teslamate[171598]:     vehicle_state: %TeslaApi.Vehicle.State.VehicleState{
Apr 28 15:21:12 tesla teslamate[171598]:       is_user_present: false,
Apr 28 15:21:12 tesla teslamate[171598]:       valet_mode: false,
Apr 28 15:21:12 tesla teslamate[171598]:       tpms_pressure_fl: 2.975,
Apr 28 15:21:12 tesla teslamate[171598]:       api_version: 54,
Apr 28 15:21:12 tesla teslamate[171598]:       valet_pin_needed: true,
Apr 28 15:21:12 tesla teslamate[171598]:       fd_window: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       last_autopark_error: "no_error",
Apr 28 15:21:12 tesla teslamate[171598]:       rp_window: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       sentry_mode: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       car_version: "2023.6.8 ca519fc096f3",
Apr 28 15:21:12 tesla teslamate[171598]:       pf: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       summon_standby_mode_enabled: false,
Apr 28 15:21:12 tesla teslamate[171598]:       remote_start_enabled: true,
Apr 28 15:21:12 tesla teslamate[171598]:       remote_start: false,
Apr 28 15:21:12 tesla teslamate[171598]:       autopark_state_v3: nil,
Apr 28 15:21:12 tesla teslamate[171598]:       dr: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       homelink_nearby: false,
Apr 28 15:21:12 tesla teslamate[171598]:       calendar_supported: true,
Apr 28 15:21:12 tesla teslamate[171598]:       timestamp: 1682688072094,
Apr 28 15:21:12 tesla teslamate[171598]:       parsed_calendar_supported: true,
Apr 28 15:21:12 tesla teslamate[171598]:       notifications_supported: true,
Apr 28 15:21:12 tesla teslamate[171598]:       software_update: %TeslaApi.Vehicle.State.VehicleState.SoftwareUpdate{
Apr 28 15:21:12 tesla teslamate[171598]:         download_perc: 0,
Apr 28 15:21:12 tesla teslamate[171598]:         expected_duration_sec: 2700,
Apr 28 15:21:12 tesla teslamate[171598]:         install_perc: 1,
Apr 28 15:21:12 tesla teslamate[171598]:         scheduled_time_ms: nil,
Apr 28 15:21:12 tesla teslamate[171598]:         ...
Apr 28 15:21:12 tesla teslamate[171598]:       },
Apr 28 15:21:12 tesla teslamate[171598]:       ft: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       odometer: 79548.755613,
Apr 28 15:21:12 tesla teslamate[171598]:       autopark_style: "dead_man",
Apr 28 15:21:12 tesla teslamate[171598]:       fp_window: 0,
Apr 28 15:21:12 tesla teslamate[171598]:       ...
Apr 28 15:21:12 tesla teslamate[171598]:     },
Apr 28 15:21:12 tesla teslamate[171598]:     vin: "xxx"
Apr 28 15:21:12 tesla teslamate[171598]:   },
Apr 28 15:21:12 tesla teslamate[171598]:   last_state_change: ~U[2023-04-28 12:23:08.129649Z],
Apr 28 15:21:12 tesla teslamate[171598]:   last_used: ~U[2023-04-28 12:42:21.858508Z],
Apr 28 15:21:12 tesla teslamate[171598]:   stream_pid: nil,
Apr 28 15:21:12 tesla teslamate[171598]:   task: nil
Apr 28 15:21:12 tesla teslamate[171598]: }
Apr 28 15:21:12 tesla teslamate[171598]: 2023-04-28 15:21:12.250 car_id=1 [info] Start / :online
Apr 28 15:21:12 tesla teslamate[171598]: 2023-04-28 15:21:12.259 car_id=1 [info] Connecting ...
Apr 28 15:21:12 tesla teslamate[171598]: 2023-04-28 15:21:12.260 [info] Car can sleep (in function can_fall_asleep). power: 0 shift_state:
Apr 28 15:21:13 tesla teslamate[171598]: 2023-04-28 15:21:13.675 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 137, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:21:12.638Z]}
Apr 28 15:21:13 tesla teslamate[171598]: 2023-04-28 15:21:13.677 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 135, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:21:13.139Z]}
Apr 28 15:21:23 tesla teslamate[171598]: 2023-04-28 15:21:23.225 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 136, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:21:23.139Z]}
Apr 28 15:21:42 tesla teslamate[171598]: 2023-04-28 15:21:42.558 [info] Car can sleep (in function can_fall_asleep). power: 0 shift_state:
Apr 28 15:21:49 tesla teslamate[171598]: 2023-04-28 15:21:49.351 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 136, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:21:48.409Z]}
Apr 28 15:22:12 tesla teslamate[171598]: 2023-04-28 15:22:12.841 [info] Car can sleep (in function can_fall_asleep). power: 0 shift_state:
Apr 28 15:22:15 tesla teslamate[171598]: 2023-04-28 15:22:15.616 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 136, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:22:14.568Z]}
Apr 28 15:22:41 tesla teslamate[171598]: 2023-04-28 15:22:41.674 [info] In Streaming API (Online): %TeslaApi.Stream.Data{elevation: 114, est_heading: 71, est_lat: 51.057609, est_lng: 13.772231, est_range: 136, heading: 71, odometer: 79548.8, power: 0, range: 199, shift_state: nil, soc: 65, speed: nil, time: ~U[2023-04-28 13:22:40.762Z]}
Apr 28 15:22:44 tesla teslamate[171598]: 2023-04-28 15:22:44.297 [info] Car can sleep (in function can_fall_asleep). power: 0 shift_state:

@markusdd
Copy link
Contributor Author

Ok, so I modified the function a little and this is interesting:
grafik

I basically pulled out the call and dumped the data we get
grafik

State says online, but everything else is nil, nevertheless Teslamate tries to pull the full state.

So...would the proper fix be to check if any of the other state are not nil and just plain ignore the state?

@micves
Copy link
Contributor

micves commented Apr 28, 2023

What does it print when its a real online (open the app)?

My experiments with TeslaPy did not show any difference in the equivalent to get_vehicle when it was a fake online compared to real online.

The only thing I found different was the power in the message from streaming. I had to start the stream to get those.
The power in vehicle_data might not be the same.
And the power in Teslamates object VehicleApi.Vehicle might be both in the sense that both messages updates the object.

@markusdd
Copy link
Contributor Author

I tried with the app and it is no different.

The car just went offline now, and I do not understand why and how this sequence happens.
At some point the API URL fails, still streaming continues, then URL fails again then this stack of vehicle is offline happens and then Teslamate decides the car is offline. This does not make any sense to me. Why is the car suddenly sleeping anyway?

grafik

@markusdd
Copy link
Contributor Author

markusdd commented Apr 28, 2023

I am still at a loss to understand how Teslamate even decides a car is now offline. That is all so confusing.

I have now 'mined' the fetch functions with logging and I cannot understand it.
Like it literally prints 'vehicle is offline', it shows offline in grafana, but the last fetch above says state is online...this is robbing my sleep.

Is it taking the 408 HTML response as a sleep indicator? What is triggering this 'fetching vehicle state...'?
And what makes it decide finally the car is online again?
grafik

@markusdd
Copy link
Contributor Author

I think I slowly understand what is going on.

I think when the car wakes up it is absolutely no problem to consider it online, even if it is the 'fake' online, as teslamate relatively quickly goes into suspended mode where it only polls the streaming API but not the state API.

I think the issue is this:
grafik

there are regulary polls to the non streaming API (not the waking one though) but when these fail (for whatever reason this happens regulary on MCU2 cars, probably when the car just wanted to go to sleep) then it triggers an uncoditional fetch_with_unreachable_assumption, the streaming API still says online, but it interrupts the 'suspended mode', hence hindering the car from truly sleeping:
grafik

I think when we are in suspended mode, and there is no reason to leave that mode (and an API call fail isn't one of them, especially if the stream is still running), there must not be a fetch of vehicle_data. That is the whole point of suspend mode.

So essentially my theory would be: if car in suspend mode, disallow those fetches.

What do you say?

@micves
Copy link
Contributor

micves commented Apr 29, 2023

I agree that it is no problem to be in online state as long as the get_vehicle_with_state is not called.

Havent looked into suspended. The what, when and how. It does make sense not to call get_vehicle_with_state in suspended.

But there are still cases that are not covered.
I'm guessing suspended is different from offline.
When we come from offline to fake online, we also do not want to call get_vehicle_with_state, as it extends the online time (or actually makes the car go from fake to real for no reason)

I have testet a little with replaced the get_vehicle_with_state with the non-waking get_vehicle.
Cant really share the log at the moment as it is in dev mode and prints millions of lines :)

Doing this replace of course makes everything weird, but I found a place to start the stream.
And when data comes in check on power:
The fake online is a power=nil
The real online (open app) is a power=0

At the moment it never goes to real online in teslamate, as this is apperantly based on get_vehicle_with_state.
I need to find a way to switch to online when stream data comes in with a 0.

Something else to think about (robbing the sleep... :D ) is what about cars that originally have the MCU2. They might act differently :|

@markusdd
Copy link
Contributor Author

markusdd commented Apr 29, 2023

suspended is not a state of the car. It is a strategy by Teslamate if nothing is going on (no_charge, no sentry, no service, no drive, no climate etc.) to not poll the API and hence let the car go to sleep.
What happens in suspended though is that apparently every 30 minutes the car is anyway being polled.
For our 'special MCU2 cars this fails with a socket closed message on the non-vehicle_data API. It is then brute-force retried on the vehicle_data API, which again leads to a wake-lock of the vehicle.
grafik
This must not happen, because exactly this sequence is what causes the majority of the phantom drain as it keeps the car awake for hours on end.

I have not yet understood though why this wakelock breaks. At some point the car just seems to 'force-sleep' and then we enter this mysterious sequence here:
grafik

I have no idea why that happens, because my surrounding print outs all still say state' online'.
But after that, teslmate decides the car is sleeping and goes to offline mode:
grafik

The next wakeup then occurs presumably when we once again have the 'fake-online' going on which teslamate picks up on and then teh wakelock start anew...

@markusdd
Copy link
Contributor Author

Here is another picture perfect example just now:

Teslamate is in suspend mode. Just Streaming API running.
Then it suddenly tries to fetch, it fails with a socket closed error, then it retries, and then we have the wakelock.

grafik

@markusdd
Copy link
Contributor Author

what is surprising is the case where it actually goes into offline. It uses a sifferent one of the fetch functions and the api response is not socket closed but nil. It then fetches again against non-vehicle_data URL and detmines the car is offline.
grafik

What does the streaming API say in those circumstances?

@markusdd
Copy link
Contributor Author

Another interesting observation:

I changed the fetch schedule in suspend mode from 30 to 60 minutes.
The data from the Streaming API does not budge. Is that by design?

This way you will never see it go offline.
Do you actually have to poll the non vehicle_data URL to find out?

@micves
Copy link
Contributor

micves commented Apr 29, 2023

As I understand it Teslamate state is based on what comes in as response from the non-vehicle_data URL.
If you print the state that the Teslamate object holds, it might not have been updated yet.
I'm guessing you are on a prod build. You can change this to :debug instead of :info
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/config/prod.exs#L9-L10
which will write alot more messages. Including the actual GET requests and responses.

And I dont think the streaming API can keep the car awake, and also not wake it up.
You have to poll either the vehicle_data or the other one to get the state.

In the code I have running now, I try to start the stream whenever there is a result in from the fetch with non-vehicle_data
The stream response is sometimes just :inactive and shortly after the car goes offline.

And I think you have some double trouble going on.
I don't have the socket close errors or timeouts (at the moment anyways)
I guess Teslamate really want some data when error occurs.
And thats just to aggressive and keeps the car awake :(

Is your car on stable internet?

@markusdd
Copy link
Contributor Author

The car is on normal LTE mobile.

Normal street parker...so no permanent Wifi for me.
Shouldn't matter, this has to work.

I might still be misunderstanding you: If the streaming API does not tell us anything about the state, why is it even being polled in suspend mode? This would seem non-sensical to me then.
What does it provide at all then compared to the normal GET requests on the non-vehicle_data URL?

The more I dig into this the less sense it makes.

@micves
Copy link
Contributor

micves commented Apr 29, 2023

Mine is also on LTE. And I agree, it has to work.

Stream tells us indirectly if its a real or a fake online based on whether power is 0 or nil.
The original idea for teslamate to keep it open must be this part:
https://github.com/adriankumpf/teslamate/blob/00cb6efd4257021d4dad64f7d8719b6677d535f5/lib/teslamate/vehicles/vehicle.ex#L407-L439

It will detect if you start charging or driving (and I guess faster than if you have to wait 30 second for it to poll vehicle_data)

@markusdd
Copy link
Contributor Author

ok that's a fair point.

But still, based on my log above: Teslmate is not polling vehicle data, yet streaming API never puts power to nil. The car is not going to sleep as per this api. But as soon as teslmate, as per schedule, tries to pull the non vehicle_data URL, it gets those weird errors like socket closed.

@micves
Copy link
Contributor

micves commented May 10, 2024

Here's some activity

@github-actions github-actions bot removed the Stale label May 11, 2024
@wodnik7
Copy link

wodnik7 commented May 14, 2024

Hello

we have a Tesla Model S100D, 2017, upgraded to MCU2 since 2022.

the car never goes to sleep, as long as we have it. Other cars on the same account (MY and MX 2016 McU1) do go sleeping properly.

can it be an issue with Teslamate? Now we have 1.28.5, but it was the same on al versions.

the issue is with the car in the attachment in the bottom. The upoer one‘s issue was the caised by eevee app (now is the working ok).

no other apps do connect to the car now

@USAFPride
Copy link

@micves, can you merge the current teslamate to your fork?

@micves
Copy link
Contributor

micves commented May 19, 2024

@USAFPride, just did a sync fork on github, so the images should be ready soon. I haven't updated and tested my own system yet.

@wodnik7, I don't think its a Teslamate issue, but maybe start a new issues with logs. There are some other issues and discussions you can look through. It could be Sentry mode is always on. It could be the 12V battery needing replacement.

@USAFPride
Copy link

@micves, all is going well on the updated image.

@zexpe
Copy link

zexpe commented May 29, 2024

I've been enjoying this fork for a few months now, not updated it to the latest version yet, but just noticed that for the first time my car is now reporting itself as being asleep rather than offline. I guess Tesla have changed something in their API?
Screenshot 2024-05-29 at 22 49 48

@Jochemp88
Copy link

I have got this situation since this morning update to 2024.14.8, so it could be that Tesla has changed something in the software rather than the API, but I'm not an expert on this.

image

@JakobLichterfeld
Copy link
Collaborator

I have got this situation since this morning update to 2024.14.8, so it could be that Tesla has changed something in the software rather than the API, but I'm not an expert on this.

Since 2024.8.3 Tesla do report only offline for Intel MCUs since Spring Update for all ECUs

@zexpe
Copy link

zexpe commented May 30, 2024

Since 2024.8.3 Tesla do report only offline for Intel MCUs since Spring Update for all ECUs

I'm MCU2 (hence using this fork), but still on 2024.8.9 since 19th April. I started using TeslaMate on 19th February when I was on 2023.44.30.9. Ever since I've used TeslaMate my car has only reported "offline" never "asleep". It started reporting "asleep" instead of offline last night - and it's still reporting "asleep" - without any software changes to the car.

@USAFPride
Copy link

2024.14.8
I'm seeing asleep, offline, online

image

@zexpe
Copy link

zexpe commented May 30, 2024

That's interesting. It also switched from offline to asleep at the same time as mine, but mine hasn't switched backed to offline since.
Screenshot 2024-05-30 at 16 10 04

@USAFPride
Copy link

@micves, can you merge the current teslamate to your fork?

Have you had any luck sorting out the errors?

@micves
Copy link
Contributor

micves commented Jun 25, 2024

@USAFPride, I just clicked the 'sync fork' on github.com (I haven't tested on own system)

I have given the errors/pending-adjustments-in-tests a thought once in a while, but nothing more.
Been too busy and as long as the PR-image (and my own dev setup) works, I tend to not prioritize it :(

I know it would make sense to get it into master at some point. Maybe I'll find some time after the summer holidays ;)

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jul 26, 2024
@JakobLichterfeld JakobLichterfeld added area:tesla api Related to the Tesla API and removed Stale labels Jul 26, 2024
@DumSkidderik
Copy link

@USAFPride, I just clicked the 'sync fork' on github.com (I haven't tested on own system)

I have given the errors/pending-adjustments-in-tests a thought once in a while, but nothing more. Been too busy and as long as the PR-image (and my own dev setup) works, I tend to not prioritize it :(

I know it would make sense to get it into master at some point. Maybe I'll find some time after the summer holidays ;)

Now we just need @leandreeberhard to update his docker image of @micves 's code (pretty please!)

@JakobLichterfeld
Copy link
Collaborator

JakobLichterfeld commented Jul 26, 2024

Now we just need @leandreeberhard to update his docker image of @micves 's code (pretty please!)

Why are you not using the official docker images from the PR? To do so follow: https://docs.teslamate.org/docs/development#testing-with-our-ci-which-builds-the-docker-images-automatically-per-pr

with pr-3262

@USAFPride
Copy link

Now we just need @leandreeberhard to update his docker image of @micves 's code (pretty please!)

Why are you not using the official docker images from the PR? To do so follow: https://docs.teslamate.org/docs/development#testing-with-our-ci-which-builds-the-docker-images-automatically-per-pr

with pr-3262

I just tried and there is some permission error:

image: ghcr.io/teslamate-org/teslamate/teslamate:pr-3262

✘ teslamate Error Head "https://ghcr.io/v2/teslamate-org/teslamate/teslamate/manifests/pr-3262": denied 0.7s Error response from daemon: Head "https://ghcr.io/v2/teslamate-org/teslamate/teslamate/manifests/pr-3262": denied

@JakobLichterfeld
Copy link
Collaborator

I just tried and there is some permission error:

Ok, strange, perhaps the build got deleted after retention days.
So we either need to extend it, or just include the changes in main version, which I prefer.

@USAFPride
Copy link

@micves, is your fork currently synched?

@micves
Copy link
Contributor

micves commented Aug 18, 2024

@USAFPride, yes a few days ago. If you subscribe to the PR here #3262 you should get e-mails whenever there are some changes.

@zexpe
Copy link

zexpe commented Oct 28, 2024

That's interesting. It also switched from offline to asleep at the same time as mine, but mine hasn't switched backed to offline since. Screenshot 2024-05-30 at 16 10 04

Mine has switched back to showing Offline instead of Asleep, since 25th October. Car firmware hasn't changed. The Tesla App still shows the car as "Asleep" so it seems Tesla have just changed the API response again?

Screenshot 2024-10-28 at 11 55 51

It was quite nice having distinct offline and asleep states, as offline would mean the car has lost its LTE connection, which happened intermittently though relatively briefly. (Or it was rebooting)

@zexpe
Copy link

zexpe commented Nov 20, 2024

Mine has switched back to showing Offline instead of Asleep, since 25th October. Car firmware hasn't changed. The Tesla App still shows the car as "Asleep" so it seems Tesla have just changed the API response again?

Screenshot 2024-10-28 at 11 55 51 It was quite nice having distinct offline and asleep states, as offline would mean the car has lost its LTE connection, which happened intermittently though relatively briefly. (Or it was rebooting)

And after finally updating to 2024.38.6 it's now gone back to "asleep" state instead of "offline". Very odd.

@mtuan293
Copy link

I still occasionally get "Asleep" instead of "Offline" as of software 2024.38.7.
Car is a 2024 Model Y Performance.
Very interesting 😁
image

@zexpe
Copy link

zexpe commented Nov 21, 2024

Interesting indeed. My car seems to have gone back to offline after its brief return to asleep following the last update!

timeline

I had a nice 5 months of the asleep condition, but that seems to be my lot!

@JakobLichterfeld JakobLichterfeld linked a pull request Dec 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tesla api Related to the Tesla API
Projects
None yet