Skip to content

Commit

Permalink
Rename proxyCert to verifyCert
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieB2B committed Jan 24, 2024
1 parent 8d412ad commit 0adbe2f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/TWCManager/Vehicle/TeslaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TeslaAPI:
'CN': 'https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/vehicles',
}
refreshClientID = "ownerapi"
proxyCert = True
verifyCert = True
carApiLastErrorTime = 0
carApiBearerToken = ""
carApiRefreshToken = ""
Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(self, master):
proxyURL = self.config["config"].get("teslaProxy", "")
if proxyURL:
self.baseURL = proxyURL + "/api/1/vehicles"
self.proxyCert = self.config["config"].get("teslaProxyCert", True)
self.verifyCert = self.config["config"].get("teslaProxyCert", True)
self.refreshClientID = self.config["config"].get(
"teslaApiClientID", "ownerapi"
)
Expand Down Expand Up @@ -242,7 +242,7 @@ def car_api_available(
"Authorization": "Bearer " + self.getCarApiBearerToken(),
}
try:
req = requests.get(url, headers=headers, verify=self.proxyCert)
req = requests.get(url, headers=headers, verify=self.verifyCert)
logger.log(logging.INFO8, "Car API cmd vehicles " + str(req))
apiResponseDict = json.loads(req.text)
except requests.exceptions.RequestException:
Expand Down Expand Up @@ -666,7 +666,7 @@ def car_api_charge(self, charge):
# Retry up to 3 times on certain errors.
for _ in range(0, 3):
try:
req = requests.post(url, headers=headers, verify=self.proxyCert)
req = requests.post(url, headers=headers, verify=self.verifyCert)
logger.log(
logging.INFO8,
"Car API cmd charge_" + startOrStop + " " + str(req),
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def setCarApiBearerToken(self, token=None):
decoded = jwt.decode(token, options={"verify_signature": False, "verify_aud": False}, leeway=datetime.timedelta(days=300))
if 'owner-api' in ''.join(decoded.get('aud', '')):
self.baseURL = self.regionURL['OwnerAPI']
elif decoder.get('ou_code', '') in self.regionURL:
elif decoded.get('ou_code', '') in self.regionURL:
self.baseURL = self.regionURL[decoded['ou_code']]
return True
else:
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def setChargeRate(self, charge_rate, vehicle=None, set_again=False):
body = {"charging_amps": charge_rate}

try:
req = requests.post(url, headers=headers, json=body, verify=self.proxyCert)
req = requests.post(url, headers=headers, json=body, verify=self.verifyCert)
logger.log(
logging.INFO8,
f"Car API cmd set_charging_amps {charge_rate}A {str(req)}",
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def wakeVehicle(self, vehicle):
"Authorization": "Bearer " + self.getCarApiBearerToken(),
}
try:
req = requests.post(url, headers=headers, verify=self.proxyCert)
req = requests.post(url, headers=headers, verify=self.verifyCert)
logger.log(logging.INFO8, "Car API cmd wake_up" + str(req))
apiResponseDict = json.loads(req.text)
except requests.exceptions.RequestException:
Expand Down Expand Up @@ -1236,7 +1236,7 @@ class CarApiVehicle:
carapi = None
__config = None
debuglevel = 0
proxyCert = None
verifyCert = None
ID = None
name = ""
syncSource = "TeslaAPI"
Expand Down Expand Up @@ -1270,7 +1270,7 @@ class CarApiVehicle:
def __init__(self, json, carapi, config):
self.carapi = carapi
self.__config = config
self.proxyCert = config["config"].get("teslaProxyCert", True)
self.verifyCert = config["config"].get("teslaProxyCert", True)
self.ID = json["id"]
self.VIN = json["vin"]
self.name = json["display_name"]
Expand Down Expand Up @@ -1340,7 +1340,7 @@ def ready(self):
# Permits opportunistic API requests
def is_awake(self):
if self.syncSource == "TeslaAPI":
url = self.carapi.getCarApiBaseURL + "/" + str(self.VIN)
url = self.carapi.getCarApiBaseURL() + "/" + str(self.VIN)
(result, response) = self.get_car_api(
url, checkReady=False, provesOnline=False
)
Expand All @@ -1367,7 +1367,7 @@ def get_car_api(self, url, checkReady=True, provesOnline=True):
# Retry up to 3 times on certain errors.
for _ in range(0, 3):
try:
req = requests.get(url, headers=headers, verify=self.proxyCert)
req = requests.get(url, headers=headers, verify=self.verifyCert)
logger.log(logging.INFO8, "Car API cmd " + url + " " + str(req))
apiResponseDict = json.loads(req.text)
# This error can happen here as well:
Expand Down Expand Up @@ -1426,7 +1426,7 @@ def update_location(self, cacheTime=60):
return True

def update_vehicle_data(self, cacheTime=60):
url = self.carapi.getCarApiBaseURL + "/"
url = self.carapi.getCarApiBaseURL() + "/"
url = url + str(self.VIN) + "/vehicle_data"
url = (
url
Expand Down Expand Up @@ -1483,7 +1483,7 @@ def apply_charge_limit(self, limit):

self.lastLimitAttemptTime = now

url = self.carapi.getCarApiBaseURL + "/"
url = self.carapi.getCarApiBaseURL() + "/"
url = url + str(self.VIN) + "/command/set_charge_limit"

headers = {
Expand All @@ -1495,7 +1495,7 @@ def apply_charge_limit(self, limit):
for _ in range(0, 3):
try:
req = requests.post(
url, headers=headers, json=body, verify=self.proxyCert
url, headers=headers, json=body, verify=self.verifyCert
)
logger.log(logging.INFO8, "Car API cmd set_charge_limit " + str(req))

Expand Down

0 comments on commit 0adbe2f

Please sign in to comment.