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

Intermittent charges incorrectly recorded #3634

Closed
1 task done
xxxarmitagexxx opened this issue Jan 28, 2024 · 15 comments
Closed
1 task done

Intermittent charges incorrectly recorded #3634

xxxarmitagexxx opened this issue Jan 28, 2024 · 15 comments
Labels
note:more information needed The reporter has to provide more information Stale undetermined Not sure if this is considered a real bug

Comments

@xxxarmitagexxx
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Our Tesla is charged at home with an EVSE with a Solar Only feature.
Consequently it can happen that the charge will stop temporarily if the sun comes down until the solar output reaches the desired 4.5kW level required by the charger.

Teslamate won't record correctly the charges in that case, only the first chunk before the charge is paused by the charger.

Here is today's use case, two charges but each with intermittent pause periods.
View from the charger app: 

First Charge: 5.2kWh

Screenshot_20240128_154304_Evnex

Second charge: 11.5kWh upon to 80%

Screenshot_20240128_154030_Evnex

Tesla app view showing the cumulative daily charge of 16kWh:

Screenshot_20240128_154101_Tesla

Teslamate: only reporting 3.12kWh and 5.97kWh with the second charge ending at 77% rather than 80% among other inconsistencies

image

Expected Behavior

Expectation is for Teslamate to record the entire charges output, without as a single charge as long as the car is plugged or multiple charges if the charging is stopped while the car is plugged.

Steps To Reproduce

No response

Relevant log output

2024-01-28 03:53:56.865 car_id=1 [info] Phase correction: 2 -> 3
2024-01-28 03:53:56.869 car_id=1 [info] Derived efficiency factor: 158.0 Wh/km (14x confirmed)
2024-01-28 03:53:56.869 car_id=1 [info] Charging / Stopped / 5.97 kWh – 47 min
2024-01-28 03:53:56.870 car_id=1 [info] Start / :online
2024-01-28 03:53:56.874 car_id=1 [info] Connecting ...
2024-01-28 03:54:01.876 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.876 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:01.877 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:06.376 [error] GenServer TeslaMate.Mqtt.Publisher terminating
** (WithClauseError) no with clause matching: {:error, :timeout}
    (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
    (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
    (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
    (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
    (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.1249662.0>): {:publish, "teslamate/cars/1/est_battery_range_km", "403.58", [retain: true, qos: 1]}
2024-01-28 03:54:06.378 [error] Task #PID<0.1249647.0> started from #PID<0.1249610.0> terminating
** (stop) exited in: GenServer.call(TeslaMate.Mqtt.Publisher, {:publish, "teslamate/cars/1/scheduled_charging_start_time", "", [retain: true, qos: 1]}, 10000)
    ** (EXIT) an exception was raised:
        ** (WithClauseError) no with clause matching: {:error, :timeout}
            (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
            (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
            (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
            (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
            (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (elixir 1.15.7) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.7) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
    Args: [#Function<4.102219062/1 in TeslaMate.Mqtt.PubSub.VehicleSubscriber.handle_info/2>, [scheduled_charging_start_time: nil]]
2024-01-28 03:54:32.575 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.575 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.576 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.576 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.576 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.576 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.577 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.577 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.577 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:32.577 [warning] MQTT publishing failed: :timeout
2024-01-28 03:54:37.076 [error] GenServer TeslaMate.Mqtt.Publisher terminating
** (WithClauseError) no with clause matching: {:error, :timeout}
    (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
    (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
    (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
    (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
    (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.1249702.0>): {:publish, "teslamate/cars/1/est_battery_range_km", "403.58", [retain: true, qos: 1]}
2024-01-28 03:54:37.078 [error] Task #PID<0.1249728.0> started from #PID<0.1249722.0> terminating
** (stop) exited in: GenServer.call(TeslaMate.Mqtt.Publisher, {:publish, "teslamate/cars/1/display_name", "Bluey", [retain: true, qos: 1]}, 10000)
    ** (EXIT) an exception was raised:
        ** (WithClauseError) no with clause matching: {:error, :timeout}
            (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
            (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
            (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
            (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
            (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (elixir 1.15.7) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.7) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
    Args: [#Function<4.102219062/1 in TeslaMate.Mqtt.PubSub.VehicleSubscriber.handle_info/2>, [display_name: "Bluey"]]
2024-01-28 03:54:37.078 [error] Task #PID<0.1249712.0> started from #PID<0.1249722.0> terminating
** (stop) exited in: GenServer.call(TeslaMate.Mqtt.Publisher, {:publish, "teslamate/cars/1/heading", "189", [retain: true, qos: 1]}, 10000)
    ** (EXIT) an exception was raised:
        ** (WithClauseError) no with clause matching: {:error, :timeout}
            (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
            (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
            (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
            (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
            (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (elixir 1.15.7) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.7) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
    Args: [#Function<4.102219062/1 in TeslaMate.Mqtt.PubSub.VehicleSubscriber.handle_info/2>, [heading: 189]]
2024-01-28 03:54:37.078 [error] Task #PID<0.1249726.0> started from #PID<0.1249722.0> terminating
** (stop) exited in: GenServer.call(TeslaMate.Mqtt.Publisher, {:publish, "teslamate/cars/1/healthy", "true", [retain: true, qos: 1]}, 10000)
    ** (EXIT) an exception was raised:
        ** (WithClauseError) no with clause matching: {:error, :timeout}
            (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
            (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
            (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
            (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
            (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (elixir 1.15.7) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.7) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
    Args: [#Function<4.102219062/1 in TeslaMate.Mqtt.PubSub.VehicleSubscriber.handle_info/2>, [healthy: true]]
2024-01-28 03:54:37.079 [error] Task #PID<0.1249731.0> started from #PID<0.1249722.0> terminating
** (stop) exited in: GenServer.call(TeslaMate.Mqtt.Publisher, {:publish, "teslamate/cars/1/sentry_mode", "false", [retain: true, qos: 1]}, 10000)
    ** (EXIT) an exception was raised:
        ** (WithClauseError) no with clause matching: {:error, :timeout}
            (tortoise 0.10.0) lib/tortoise.ex:269: Tortoise.publish/4
            (teslamate 1.28.2) lib/teslamate/mqtt/publisher.ex:41: TeslaMate.Mqtt.Publisher.handle_call/3
            (stdlib 5.1.1) gen_server.erl:1113: :gen_server.try_handle_call/4
            (stdlib 5.1.1) gen_server.erl:1142: :gen_server.handle_msg/6
            (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (elixir 1.15.7) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.15.7) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
    Args: [#Function<4.102219062/1 in TeslaMate.Mqtt.PubSub.VehicleSubscriber.handle_info/2>, [sentry_mode: false]]

Screenshots

No response

Additional data

No response

Type of installation

Docker

Version

v1.28.2

@dyxyl
Copy link
Contributor

dyxyl commented Jan 29, 2024

Can you post the rest of the log from 28th Jan? I think the part you posted doesn't show the time when charging should have started again (I assume your time is currently UTC+11 and the time in the log is UTC).

@xxxarmitagexxx
Copy link
Author

Hi,

Yes the logs timestamps are in UTC while Teslamate is set as UTC+11.

Please find attached the logs starting on the 27th 1pm UTC up until 28th 1pm UTC which should encapsulate both charges

teslamate.log

@xxxarmitagexxx
Copy link
Author

While yesterday charge lined up well between the charger data and Teslamate, today's charge is missing 20+ minutes at the start in Teslamate and is thus under reported: 

WhatsApp Image 2024-01-30 à 13 47 43_c1359fa6

image

teslamate_30.log

The Tesla app is correctly reporting 9kWh similar to the charger.

Any idea what's causing the erratic behavior as the charge reporting cannot be trusted as it stands ?
This time the charge once started was continuous unlike the prior examples.

@wooter
Copy link
Contributor

wooter commented Jan 30, 2024

Intermitted charging and driving logging is possibly related to a change in the API endpoint, see #3629. However, your charging durations are longer as "typical" for this issue, see #3635.

A fix for the API endpoint change in the works, #3630.

@dyxyl
Copy link
Contributor

dyxyl commented Jan 30, 2024

It looks like communication errors between the car and Tesla:

2024-01-30 00:39:50.107 [warning] GET https://owner-api.teslamotors.com/api/1/vehicles/.../vehicle_data -> 540 (2975.551 ms)
2024-01-30 00:39:50.107 [warning] TeslaApi.Error / vehicle error: it is online but not responsive
2024-01-30 00:39:50.107 car_id=1 [error] Error / :unknown
2024-01-30 00:40:10.617 car_id=1 [info] Suspending logging
2024-01-30 00:40:32.921 [warning] Too many disconnects from streaming API

I think the vehicle error: it is online but not responsive comes from the Tesla server.

Maybe a weak WiFi signal where the car is parked?

@xxxarmitagexxx
Copy link
Author

xxxarmitagexxx commented Jan 30, 2024 via email

@dyxyl
Copy link
Contributor

dyxyl commented Jan 30, 2024

While they aren't related to the car, are the large number of MQTT timeouts expected?

@xxxarmitagexxx
Copy link
Author

xxxarmitagexxx commented Jan 30, 2024 via email

@JakobLichterfeld JakobLichterfeld added undetermined Not sure if this is considered a real bug note:more information needed The reporter has to provide more information labels Feb 1, 2024
@JakobLichterfeld
Copy link
Collaborator

TeslaMate wait for the car to fall asleep when the charge has stopped, and thus can be still in the state of waiting for sleep when you start charging again. This can only be prevented when forcing the car to be awake, or resume TeslaMate logging before start the charge again.

Copy link
Contributor

github-actions bot commented Mar 5, 2024

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 Mar 5, 2024
@micves
Copy link
Contributor

micves commented Mar 5, 2024

TeslaMate wait for the car to fall asleep when the charge has stopped, and thus can be still in the state of waiting for sleep when you start charging again. This can only be prevented when forcing the car to be awake, or resume TeslaMate logging before start the charge again.

If streaming is enabled it should automatically start logging again on its own:

%Stream.Data{shift_state: s, power: power}
when s in [nil, "P"] and is_number(power) and power < 0 ->
Logger.info("Charging detected: #{power} kW", car_id: data.car.id)
{:next_state, prev_state, data, schedule_fetch(0, data)}

@xxxarmitagexxx
Copy link
Author

xxxarmitagexxx commented Mar 5, 2024 via email

@github-actions github-actions bot removed the Stale label Mar 6, 2024
@micves
Copy link
Contributor

micves commented Mar 8, 2024

Maybe you have streaming connection problems when the charge start, which of course would make it not detect the charge.

Maybe the MQTT errors also causes issues. In the log it only seems to be [error] GenServer TeslaMate.Mqtt.Publisher terminating, but it could still mess up the rest of the system.

If you have an interface to the charger, it could help to wake up teslamate, similar to this:
#3701

@xxxarmitagexxx
Copy link
Author

xxxarmitagexxx commented Mar 8, 2024 via email

Copy link
Contributor

github-actions bot commented Apr 8, 2024

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 Apr 8, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note:more information needed The reporter has to provide more information Stale undetermined Not sure if this is considered a real bug
Projects
None yet
Development

No branches or pull requests

5 participants