Skip to content

Commit

Permalink
BF: AC charging detection with FleetAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Aug 27, 2024
1 parent 5e33efb commit a14e6f5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion TeslaLogger/TelemetryConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal class TelemetryConnection
public DateTime lastVehicleSpeedDate = DateTime.MinValue;
public double lastVehicleSpeed = 0.0;

public String lastChargeState = "";

public int lastposid = 0;


Expand Down Expand Up @@ -615,6 +617,18 @@ private void InsertBatteryTable(dynamic j, DateTime date, string resultContent)
System.Diagnostics.Debug.WriteLine("PackCurrent: " + d);
lastPackCurrent = d;
lastPackCurrentDate = date;

if (!acCharging && lastChargeState == "Enable")
{
var current = PackCurrent(j, date);

if (current > 2)
{
Log($"AC Charging {current}A ***");
InsertLocation(j, date, resultContent, true);
acCharging = true;
}
}
}
}
}
Expand Down Expand Up @@ -691,6 +705,12 @@ void handleStatemachine(dynamic j, DateTime date, string resultContent)

if (key == "ChargeState")
{
if (lastChargeState != v1)
{
lastChargeState = v1;
Log("ChargeState " + lastChargeState);
}

if (v1 == "Enable")
{
if (Driving)
Expand All @@ -703,9 +723,9 @@ void handleStatemachine(dynamic j, DateTime date, string resultContent)
{
var current = PackCurrent(j, date);

Log($"AC Charging {current}A ***");
if (current > 2)
{
Log($"AC Charging {current}A ***");
InsertLocation(j, date, resultContent, true);
acCharging = true;
}
Expand All @@ -718,6 +738,10 @@ void handleStatemachine(dynamic j, DateTime date, string resultContent)
Log("Stop AC Charging ***");
acCharging = false;
}
}
else if (v1 == "QualifyLineConfig")
{

}
else
{
Expand Down

0 comments on commit a14e6f5

Please sign in to comment.