diff --git a/lib/TWCManager/TWCSlave.py b/lib/TWCManager/TWCSlave.py index 8189f484..962a0524 100644 --- a/lib/TWCManager/TWCSlave.py +++ b/lib/TWCManager/TWCSlave.py @@ -543,20 +543,6 @@ def send_master_heartbeat(self): # Car is not charging and is not reporting an error state, so # try starting charge via car api. self.master.startCarsCharging() - elif self.reportedAmpsActual >= 1.0: - # At least one plugged in car is successfully charging. We don't - # know which car it is, so we must set - # vehicle.stopAskingToStartCharging = False on all vehicles such - # that if any vehicle is not charging without us calling - # car_api_charge(False), we'll try to start it charging again at - # least once. This probably isn't necessary but might prevent - # some unexpected case from never starting a charge. It also - # seems less confusing to see in the output that we always try - # to start API charging after the car stops taking a charge. - for vehicle in self.master.getModuleByName( - "TeslaAPI" - ).getCarApiVehicles(): - vehicle.stopAskingToStartCharging = False self.master.getModulesByType("Interface")[0]["ref"].send( bytearray(b"\xFB\xE0") diff --git a/lib/TWCManager/Vehicle/TeslaAPI.py b/lib/TWCManager/Vehicle/TeslaAPI.py index e398b1ce..34fa1e76 100644 --- a/lib/TWCManager/Vehicle/TeslaAPI.py +++ b/lib/TWCManager/Vehicle/TeslaAPI.py @@ -645,12 +645,17 @@ def car_api_charge(self, charge): if not vehicle.atHome: # Vehicle is not at home, so don't change its charge state. - logger.info( + message = ( vehicle.name + " is not at home. Do not " + startOrStop + " charge." ) + # Stop asking to start charging when not at home. + if startOrStop == "start": + vehicle.stopAskingToStartCharging = True + message += " Stop asking to start charging." + logger.info(message) continue # If you send charge_start/stop less than 1 second after calling @@ -1264,6 +1269,7 @@ def wakeVehicle(self, vehicle): elif req.status_code == 429: # We're explicitly being told to back off self.errorCount = max(30, self.errorCount) + self.updateCarApiLastErrorTime(vehicle) return False except json.decoder.JSONDecodeError: return False @@ -1435,6 +1441,7 @@ def get_car_api(self, url, checkReady=True, provesOnline=True): elif req.status_code == 429: # We're explicitly being told to back off self.errorCount = max(30, self.errorCount) + self.carapi.updateCarApiLastErrorTime(self) return False, None except json.decoder.JSONDecodeError: pass @@ -1474,7 +1481,7 @@ def get_car_api(self, url, checkReady=True, provesOnline=True): self.carapi.updateCarApiLastErrorTime(self) return (False, None) - def update_location(self, cacheTime=60): + def update_location(self, cacheTime=300): if self.syncSource == "TeslaAPI": return self.update_vehicle_data(cacheTime) @@ -1485,7 +1492,7 @@ def update_location(self, cacheTime=60): return True - def update_vehicle_data(self, cacheTime=60): + def update_vehicle_data(self, cacheTime=300): url = ( "/".join([self.carapi.getCarApiBaseURL(), str(self.VIN), "vehicle_data"]) + "?endpoints="