-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to support scheduled charging
- Loading branch information
1 parent
6cb396c
commit 3d9a0b6
Showing
5 changed files
with
260 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,75 @@ def stopChargeVehicle(vin): | |
|
||
|
||
## | ||
# Uses new endpoint to add a schedule for vehicle charging. | ||
# Scheduled Time is in minutes, e.g. 7:30 AM = | ||
# (7 * 60) + 30 = 450 | ||
# | ||
# author: [email protected] | ||
## | ||
def addChargeSchedule(vin, lat, lon, start_time, id): | ||
try: | ||
if vin == M3_VIN: | ||
return TeslaVehicleCommandProxy.addChargeSchedule(vin, lat, lon, start_time, id) | ||
|
||
url = (BASE_OWNER_URL | ||
+ '/vehicles/' | ||
+ getVehicleId(vin) | ||
+ '/command/add_charge_schedule') | ||
|
||
payload = { | ||
'days_of_week': 'All', | ||
'enabled': True, | ||
'start_enabled': True, | ||
'end_enabled': False, | ||
'lat': lat, | ||
'lon': lon, | ||
'start_time': start_time, | ||
'one_time': False, | ||
'id': id | ||
} | ||
|
||
return requests.post( | ||
url, | ||
json=payload, | ||
headers={'authorization': 'Bearer ' + ACCESS_TOKEN} | ||
) | ||
except Exception as e: | ||
logError('addChargeSchedule(' + vin + '): ' + str(e)) | ||
|
||
|
||
## | ||
# Uses new endpoint to remove a schedule for vehicle charging. | ||
# | ||
# author: [email protected] | ||
## | ||
def removeChargeSchedule(vin, id): | ||
try: | ||
if vin == M3_VIN: | ||
return TeslaVehicleCommandProxy.removeChargeSchedule(vin, id) | ||
|
||
url = (BASE_OWNER_URL | ||
+ '/vehicles/' | ||
+ getVehicleId(vin) | ||
+ '/command/remove_charge_schedule') | ||
|
||
payload = { | ||
'id': id | ||
} | ||
|
||
return requests.post( | ||
url, | ||
json=payload, | ||
headers={'authorization': 'Bearer ' + ACCESS_TOKEN} | ||
) | ||
except Exception as e: | ||
logError('removeChargeSchedule(' + vin + '): ' + str(e)) | ||
|
||
|
||
## | ||
# Per Tesla (https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-commands#set-scheduled-charging): | ||
# This endpoint is not recommended beginning with firmware version 2024.26. | ||
# | ||
# Sends command and parameter to set a specific vehicle to charge | ||
# at a scheduled time. Scheduled Time is in minutes, e.g. 7:30 AM = | ||
# (7 * 60) + 30 = 450 | ||
|
@@ -131,6 +200,9 @@ def setScheduledCharging(vin, time): | |
|
||
|
||
## | ||
# Per Tesla (https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-commands#set-scheduled-departure): | ||
# This endpoint is not recommended beginning with firmware version 2024.26. | ||
# | ||
# Sends command and parameters to set a specific vehicle to charge and/or | ||
# precondition by a departure time. Departure Time and Off-Peak Charge End | ||
# Time are in minutes, e.g. 7:30 AM = (7 * 60) + 30 = 450 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,8 @@ def getVehicleData(vin): | |
+ 'vehicle_state;' | ||
+ 'gui_settings;' | ||
+ 'vehicle_config;' | ||
+ 'closures_state;' | ||
+ 'drive_state')) | ||
+ 'drive_state;' | ||
+ 'charge_schedule_data')) | ||
|
||
urllib3.disable_warnings(urllib3.exceptions.SubjectAltNameWarning) | ||
|
||
|
@@ -101,8 +101,76 @@ def stopChargeVehicle(vin): | |
except Exception as e: | ||
logError('stopChargeVehicle(' + vin + '): ' + str(e)) | ||
|
||
## | ||
# Uses new endpoint to add a schedule for vehicle charging. | ||
# Scheduled Time is in minutes, e.g. 7:30 AM = | ||
# (7 * 60) + 30 = 450 | ||
# | ||
# author: [email protected] | ||
## | ||
def addChargeSchedule(vin, lat, lon, start_time, id): | ||
try: | ||
url = (BASE_PROXY_URL | ||
+ '/vehicles/' | ||
+ vin | ||
+ '/command/add_charge_schedule') | ||
|
||
payload = { | ||
'days_of_week': 'All', | ||
'enabled': True, | ||
'start_enabled': True, | ||
'end_enabled': False, | ||
'lat': lat, | ||
'lon': lon, | ||
'start_time': start_time, | ||
'one_time': False, | ||
'id': id | ||
} | ||
|
||
urllib3.disable_warnings(urllib3.exceptions.SubjectAltNameWarning) | ||
|
||
return requests.post( | ||
url, | ||
json=payload, | ||
headers={'authorization': 'Bearer ' + ACCESS_TOKEN}, | ||
verify=CERT | ||
) | ||
except Exception as e: | ||
logError('addChargeSchedule(' + vin + '): ' + str(e)) | ||
|
||
|
||
## | ||
# Uses new endpoint to remove a schedule for vehicle charging. | ||
# | ||
# author: [email protected] | ||
## | ||
def removeChargeSchedule(vin, id): | ||
try: | ||
url = (BASE_PROXY_URL | ||
+ '/vehicles/' | ||
+ vin | ||
+ '/command/remove_charge_schedule') | ||
|
||
payload = { | ||
'id': id | ||
} | ||
|
||
urllib3.disable_warnings(urllib3.exceptions.SubjectAltNameWarning) | ||
|
||
return requests.post( | ||
url, | ||
json=payload, | ||
headers={'authorization': 'Bearer ' + ACCESS_TOKEN}, | ||
verify=CERT | ||
) | ||
except Exception as e: | ||
logError('removeChargeSchedule(' + vin + '): ' + str(e)) | ||
|
||
|
||
## | ||
# Per Tesla (https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-commands#set-scheduled-charging): | ||
# This endpoint is not recommended beginning with firmware version 2024.26. | ||
# | ||
# Sends command and parameter to set a specific vehicle to charge | ||
# at a scheduled time. Scheduled Time is in minutes, e.g. 7:30 AM = | ||
# (7 * 60) + 30 = 450 | ||
|