Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vehicle without vin #133

Closed
pbe-axelor opened this issue Mar 7, 2023 · 5 comments · Fixed by #137
Closed

vehicle without vin #133

pbe-axelor opened this issue Mar 7, 2023 · 5 comments · Fixed by #137
Labels

Comments

@pbe-axelor
Copy link
Contributor

client.get_vehicles() can return vehicles that don't have any vin

This is associated to a multimedia system Touch & Go. Here is an example of the data :

{
    'vin': '',
    'brand': 'TOYOTA',
    'deviceId': '[REDACTED]',
    'generation': '[REDACTED]'',
    'deviceTypeName': '[REDACTED]'',
    'navType': 'TOY',
    'navSubType': 'Low',
    'source': 'NMSC'
  }

This cause 404 Not Found issues when trying to fetch the vehicle status from client.get_vehicle_status(car) and integration fail to setup.

ERROR (MainThread) [custom_components.toyota] Error fetching toyota data: HTTP: 400 - {"timestamp":1677989012440,"status":400,"error":"Bad Request","message":"INVALID VIN FORMAT","errorCode":"CMA400"}
ERROR (MainThread) [custom_components.toyota] Error fetching toyota data: HTTP: 404 - <!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="utf-8">
 <title>Error</title>
 </head>
 <body>
 <pre>Cannot GET /vehicle/user/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/vehicle/</pre>
 </body>
 </html>
@DurgNomis-drol
Copy link
Owner

All cars are given a VIN number. So I am not sure that I understand.

What car do you have and what model year? Are you connecting your car or are you connecting the headunit?

@pbe-axelor
Copy link
Contributor Author

Yes, there is no vin associated to the car returned by client.get_vehicles().

Using that script, https://github.com/DurgNomis-drol/mytoyota#usage, here are the cars returned :

[
  {
    'id': [REDACTED],
    'vin': '[REDACTED]',
    'isNC': False,
    'isOneAppMigrated': False,
    'alias': 'RAV4 PHEV',
    'owner': False,
    'vehicleAddedOn': '[REDACTED]',
    'isEntitled': True,
    'entitledBy': 'CUSTOMER',
    'entitledOn': '[REDACTED]',
    'ownerFlag': False,
    'source': 'NMSC',
    'horsePower': 185,
    'hybrid': True,
    'fuel': 'PETROL',
    'engine': '2.5 TNGA PHEV',
    'transmissionType': 'CVT',
    'transmission': 'Continuously Variable Transmission',
    'grade': 'Limited',
    'modelName': 'RAV4 PHEV',
    'modelCode': 'RE',
    'interiorColour': '20',
    'exteriorColour': '2QZ ',
    'imageUrl': '[REDACTED]',
    'deliveryCountry': 'FR',
    'productionDate': '2021-04-22',
    'modelDocumentId': '[REDACTED]',
    'productionYear': '2021',
    'licensePlate': '[REDACTED]',
    'modelDescription': 'RAV4 PHEV'
  },
  {
    'vin': '',
    'brand': 'TOYOTA',
    'deviceId': '[REDACTED]',
    'generation': 'MM17PLUS',
    'deviceTypeName': 'ToyotaTouch2 MM19',
    'navType': 'TOY',
    'navSubType': 'Low',
    'source': 'NMSC'
  }
]

The first entry is the RAV4 PHEV car, the second is the multimedia system associated to the car.

@DurgNomis-drol
Copy link
Owner

Right, it seems that Toyota have chosen to make a separat entry for their nav units. Right now this is not supported, and I don't have access to a car that does this. So I can't tell what needs to be done for this to work. Allowing vehicles without a vin number, will not add support for these navunits anyways. But we should add a check that just ignores cars with no vin number so the we don't get an error.

@pbe-axelor
Copy link
Contributor Author

Allowing vehicles without a vin number, will not add support for these navunits anyways.

Yes, agree with that.

But we should add a check that just ignores cars with no vin number so the we don't get an error.

I solved the issue by adding a check while iterating over cars :

             cars = await with_timeout(client.get_vehicles())
 
             for car in cars:
+                if not car['vin']:
+                    continue
+
                 vehicle = await client.get_vehicle_status(car)

I can submit a PR if you want.

@DurgNomis-drol
Copy link
Owner

Please do 😃 Contributions are always welcome

DurgNomis-drol pushed a commit that referenced this issue Mar 16, 2023
Fixes #133

Signed-off-by: Pierre Belloy <p.belloy@axelor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants