Replies: 3 comments
-
good idea. While doing some tests with the fleet API, I had the same need to pass the endpoints via env variables. It might be useful to make this dynamic. Another point, I prepared an endpoint which creates/destroys TeslaMate envs on demand (in order to test the PR branches of the CI for example). |
Beta Was this translation helpful? Give feedback.
-
The wake-up from sleep issue I described above has been addressed in #3508. |
Beta Was this translation helpful? Give feedback.
-
Wonder how often the Suspect I am not doing it often enough, which can lead to crashes from Teslamate. At present, only updating it when car is driving. But maybe I need to update it for every
This can be reproduced by starting TeslaMate with an empty database when the car is asleep, and waking the car up. When TeslaMate notices the car is awake it will crash, repeatedly try to restart, and terminate. But only under those exact circumstances. In the above run, I have the following patch: diff --git a/lib/teslamate/log.ex b/lib/teslamate/log.ex
index 8875f0a1..0cf7d932 100644
--- a/lib/teslamate/log.ex
+++ b/lib/teslamate/log.ex
@@ -57,6 +57,11 @@ defmodule TeslaMate.Log do
def start_state(%Car{} = car, state, opts \\ []) when not is_nil(state) do
now = Keyword.get(opts, :date) || DateTime.utc_now()
+ IO.puts("------------------------------------------------")
+ IO.inspect(now)
+ IO.inspect(System.os_time(:second))
+ IO.inspect(System.os_time() |> DateTime.from_unix!(:native, Calendar.ISO))
+ IO.puts("------------------------------------------------") Don't get confused, now is not necessarily now, it could be the parameter also. Spent ages trying to debug this... The above output shows that the Also wondering if this could lead to crashes, if e.g. the clock on the TeslaMate computer is not synchronised correctly. |
Beta Was this translation helpful? Give feedback.
-
Hello,
Maybe I am crazy, but I have started writing an API simulator, to simulate the real Tesla API.
At present only a limited selection of calls available from the Auth, REST, and Streaming APIs. i.e. everything that TeslaMate uses. Plus the wake_up call. And a API call to control the simulated cars. The newer proto based API is not supported (in theory it could be if I got the required information from Tesla).
It also has command line clients (and Rust API) to connect to the API and retrieve information. Including the streaming API.
https://github.com/brianmay/fake_luxary_api
The idea is that this can be used to simulate various error conditions, driving conditions, etc, that might be otherwise hard to test on the real API.
Basically, to run, install rust compiler, and then run:
And then connect Teslamate to it. Or run one of the test programs against it (instructions in the
README.md
for the repo).Currently the endpoints in Teslamate are hard-coded, so using this requires the following changes (I think these need to be modified to come from environment variables and use defaults if the environment variables are not set):
Oh, in case not obvious, you probably should only use this with a throw away Teslmate instance, with a throw away Database and MQTT server. Who knows what it might try to do if you use it on your live database.
I use my nix flake myself to create a dev environment: #3485
Currently the simulation is limited. Fixed 2 cars. Fixed base data. Data from what Github Copilot suggested.
Driving starts from a fixed location in San Francisco and heads directly North. And doesn't stop when it reaches water. Support for changing the heading is there, not tested (wonder if I got the math correct?). 0 to 60mph[*] instantly. Who cares about roads? Stops when it runs out of battery. And it simulates a perfect car with no errors, only sleep mode. Even that is somewhat perfect compared with the real thing. After wake_up returns no error, the car really is awake. More realism can be added though.
Simulated battery is 20miles every 10% battery, and charges at 10% every minute at 48 amps.
I have seen random TeslaMate crashes with this. Which may or may not be my fault. At least one might be fixed, not sure. It was intermittent, and caused TeslaMate to completely exit and stop running.
Another issue I have noticed, when car goes to sleep, Teslamate repeatedly tries to reconnect to the streaming for a while, and then shows up with a big red error:
At this point it notices that the car is offline, and stops trying to connect. Have to watch the sleep process on a real car, see if it does the same thing or not.
[*] use of USA units is because the API is based on USA units.
Regards
Beta Was this translation helpful? Give feedback.
All reactions