mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 17:06:18 +00:00
handle error in get_charge_hour
This commit is contained in:
+11
-7
@@ -366,13 +366,17 @@ class MyPSACC:
|
||||
reg = r"PT([0-9]{1,2})H([0-9]{1,2})?"
|
||||
data = self.get_vehicle_info(vin)
|
||||
hour_str = data.energy[0].charging.next_delayed_time
|
||||
hour = re.findall(reg, hour_str)[0]
|
||||
h = int(hour[0])
|
||||
if hour[1] == '':
|
||||
m = 0
|
||||
else:
|
||||
m = hour[1]
|
||||
return h, m
|
||||
try:
|
||||
hour = re.findall(reg, hour_str)[0]
|
||||
h = int(hour[0])
|
||||
if hour[1] == '':
|
||||
m = 0
|
||||
else:
|
||||
m = hour[1]
|
||||
return h, m
|
||||
except IndexError:
|
||||
logger.error(traceback.format_exc())
|
||||
logger.error(f"Can't get charge hour: {hour_str}")
|
||||
|
||||
def get_charge_status(self, vin):
|
||||
data = self.get_vehicle_info(vin)
|
||||
|
||||
Reference in New Issue
Block a user