handle error in get_charge_hour

This commit is contained in:
Florian Bezannier
2021-03-06 16:53:15 +01:00
parent 56883083b4
commit 5cac905cfd
+11 -7
View File
@@ -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)