Skip to content

Commit

Permalink
Merge pull request #574 from RichieB2B/fix-stopAskingToStartCharging
Browse files Browse the repository at this point in the history
Only reset stopAskingToStartCharging on policy change
  • Loading branch information
ngardiner committed Apr 2, 2024
2 parents 2dbb72c + 4227a01 commit 2a6a914
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/TWCManager/Policy/Policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2a6a914

Please sign in to comment.