Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't attempt to start or stop charging a disconnected car #577

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/TWCManager/Vehicle/TeslaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,16 @@ def car_api_charge(self, charge):
# more than once per minute.
self.updateLastStartOrStopChargeTime()

# Don't attempt to start or stop charging a disconnected car.
if vehicle.chargingState == "Disconnected":
logger.info(
vehicle.name
+ " is disconnected. Do not "
+ startOrStop
+ " charge."
)
continue

# only start/stop charging cars parked at home.

if vehicle.update_location() is False:
Expand Down Expand Up @@ -727,16 +737,14 @@ def car_api_charge(self, charge):
"complete",
"charging",
"is_charging",
"disconnected",
"requested",
]:
# We asked the car to charge, but it responded
# that it can't, either because it's reached
# target charge state (reason == 'complete'), or
# it's already trying to charge (reason ==
# 'charging' or 'requested') or it's not
# connected to a charger (reason ==
# 'disconnected'). In these cases, it won't help
# 'charging' or 'requested').
# In these cases, it won't help
# to keep asking it to charge, so set
# vehicle.stopAskingToStartCharging = True.
#
Expand Down Expand Up @@ -1277,6 +1285,7 @@ class CarApiVehicle:
lon = 10000
atHome = False
timeToFullCharge = 0.0
chargingState = ""

# Sync values are updated by an external module such as TeslaMate
syncTimestamp = 0
Expand Down Expand Up @@ -1471,6 +1480,7 @@ def update_vehicle_data(self, cacheTime=60):
self.chargeLimit = charge["charge_limit_soc"]
self.batteryLevel = charge["battery_level"]
self.timeToFullCharge = charge["time_to_full_charge"]
self.chargingState = charge.get("charging_state", "")

self.lastVehicleStatusTime = now

Expand Down
Loading