def get_status_from_update(self, request_id):
        try:
            status_service = VehicleStatusReportService(self.api, self.vehicle)
            return status_service.get_request_status(request_id).status

        except Exception:
            pass
Beispiel #2
0
 def updateVehicleStatusReport(self):
     try:
         status_service = VehicleStatusReportService(self.api, self.vehicle)
         status = status_service.get_stored_vehicle_data()
         self.vehicle.state = {status.data_fields[i].name: status.data_fields[i].value for i in range(0, len(status.data_fields))}
         self.vehicle.state["last_update_time"] = datetime.strptime(status.data_fields[0].send_time, '%Y-%m-%dT%H:%M:%S')
     except Exception:
         pass
Beispiel #3
0
 def refresh_vehicle_data(self):
     try:
         status_service = VehicleStatusReportService(self.api, self.vehicle)
         res = status_service.request_current_vehicle_data()
         return res.request_id
     
     except Exception:
         pass
Beispiel #4
0
    def _probe(self):
        api = API()
        logon_service = LogonService(api)
        if not logon_service.restore_token():
            # We need to login
            with open(self.cred_file) as data_file:
                login_data = json.load(data_file)
            logon_service.login(login_data['user'], login_data['pass'])

        car_service = CarService(api)
        vehicles_response = car_service.get_vehicles()
        data = ValueSet()
        for vehicle in vehicles_response.vehicles:
            if self.vin != vehicle.vin:
                continue

            status_report_service = VehicleStatusReportService(api, vehicle)
            report = status_report_service.get_stored_vehicle_data()
            assert isinstance(report, VehicleDataResponse)
            for field in report.data_fields:
                if field.name == 'UTC_TIME_AND_KILOMETER_STATUS':
                    data.add(Value(int(field.value),
                                   name='kilometers'))  # int in km
                    continue
                if field.name == 'TEMPERATURE_OUTSIDE':
                    data.add(
                        Value(int(int(field.value) / 10 - 273),
                              name='temp.outsite'))
                    continue
                if field.name == 'TOTAL_RANGE':
                    data.add(Value(int(field.value),
                                   name='range.total'))  # int in km
                    continue
                if field.name == 'TANK_LEVEL_IN_PERCENTAGE':
                    data.add(Value(int(field.value),
                                   name='tankLevel'))  # int in %
                    continue
                if field.name == 'OIL_LEVEL_DIPSTICKS_PERCENTAGE':
                    data.add(Value(float(field.value),
                                   name='oilLevelPercent'))  # in %
                    continue
                if field.name == 'ADBLUE_RANGE':
                    data.add(Value(int(field.value),
                                   name='range.adblue'))  # int in km
                    continue

            return data

        print('VIN not found')
        return None
Beispiel #5
0
    def get_status_from_update(self, request_id):
        try:
            status_service = VehicleStatusReportService(self.api, self.vehicle)
            return status_service.get_request_status(request_id).status
        
        except Exception:
            pass


    # def get_status(self, timeout = 10):
    #     """Check status from call"""
    #     retry_counter = 0
    #     while retry_counter < timeout:
    #         resp = self.call('-/emanager/get-notifications', data='dummy')
    #         data = resp.get('actionNotificationList', {})
    #         if data:
    #             return data
    #         time.sleep(1)
    #         retry_counter += 1
    #     return False