From 4227a01ec6a1a9ed82351d0d433a423242238d5c Mon Sep 17 00:00:00 2001 From: Richard van den Berg Date: Tue, 2 Apr 2024 09:10:45 +0200 Subject: [PATCH] fix: only reset stopAskingToStartCharging on policy change, fixed #573 --- lib/TWCManager/Policy/Policy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/TWCManager/Policy/Policy.py b/lib/TWCManager/Policy/Policy.py index 71ff859d..67e6dc44 100644 --- a/lib/TWCManager/Policy/Policy.py +++ b/lib/TWCManager/Policy/Policy.py @@ -194,6 +194,11 @@ def enforcePolicy(self, policy, updateLatch=False): self.limitOverride = False self.fireWebhook("enter") + # Clear stopAskingToStartCharging so we try charging each car at + # least once + for vehicle in self.master.getModuleByName("TeslaAPI").getCarApiVehicles(): + vehicle.stopAskingToStartCharging = False + if updateLatch and "latch_period" in policy: policy["__latchTime"] = time.time() + policy["latch_period"] * 60 @@ -229,11 +234,6 @@ def enforcePolicy(self, policy, updateLatch=False): limit = -1 self.master.queue_background_task({"cmd": "applyChargeLimit", "limit": limit}) - # Clear stopAskingToStartCharging so we try charging each car at - # least once - for vehicle in self.master.getModuleByName("TeslaAPI").getCarApiVehicles(): - vehicle.stopAskingToStartCharging = False - # Report current policy via Status modules for module in self.master.getModulesByType("Status"): module["ref"].setStatus(