Skip to content

Commit

Permalink
GetRegion only if car is online
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Feb 1, 2024
1 parent 7d19b9a commit a00e048
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions TeslaLogger/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,9 @@ private void HandleState_Start()
{
//Log(res);
SetCurrentState(TeslaState.Online);
if (FleetAPI && String.IsNullOrEmpty(FleetApiRegionURL))
webhelper.GetRegion();

webhelper.IsDriving(true);
webhelper.ResetLastChargingState();
DbHelper.StartState(res);
Expand Down
8 changes: 8 additions & 0 deletions TeslaLogger/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ public string GetRegion()
if (!car.FleetAPI)
return "";

var state = car.GetCurrentState();

if (!(state == Car.TeslaState.Charge
|| state == Car.TeslaState.Drive
|| state == Car.TeslaState.Online))
return "";


var response = GethttpclientTeslaAPI().GetAsync(new Uri("https://teslalogger.de:4444/api/1/users/region")).Result;
string result = response.Content.ReadAsStringAsync().Result;
if (response.IsSuccessStatusCode)
Expand Down

0 comments on commit a00e048

Please sign in to comment.