diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 752a636..a301ba4 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -12,9 +12,8 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: -1. what solution did you use (solution 1 or 2) -2. what command did you use -3. when the bug append ? +1. what command did you use +2. when the bug append ? **Config file** Give the anonymize content of the config file @@ -22,6 +21,7 @@ Give the anonymize content of the config file **Environment (please complete the following information):** - OS: [e.g. Windows] - Android app Version [e.g. 26.0] + - Brand and model of car **Additional context** Add any other context about the problem here. diff --git a/MyPSACC.py b/MyPSACC.py index a4997b3..90d8a99 100644 --- a/MyPSACC.py +++ b/MyPSACC.py @@ -227,7 +227,7 @@ class MyPSACC: headers={ "Connection": "Keep-Alive", "User-Agent": "okhttp/4.8.0", - "x-introspect-realm": "clientsB2CPeugeot" + "x-introspect-realm": self.realm }) return res @@ -362,13 +362,17 @@ class MyPSACC: reg = r"PT([0-9]{1,2})H([0-9]{1,2})?" data = self.get_vehicle_info(vin) hour_str = data.get_energy('Electric').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) diff --git a/web/callback.py b/web/callback.py index eb426e3..3e04325 100644 --- a/web/callback.py +++ b/web/callback.py @@ -78,9 +78,16 @@ def preconditioning(vin, activate): @app.route('/position/') def get_position(vin): res = myp.get_vehicle_info(vin) - longitude, latitude = res.last_position.geometry.coordinates - return jsonify( - {"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"}) + coordinates=res.last_position.geometry.coordinates + if len(coordinates)==3: # altitude is not always availlable + longitude, latitude, altitude = coordinates + return jsonify( + {"longitude": longitude, "latitude": latitude, "altitude": altitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"}) + else: + longitude, latitude = coordinates + return jsonify( + {"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"}) + # Set a battery threshold and schedule an hour to stop the charge