DurgNomis-drol / mytoyota

Python client for Toyota Connected Services API
MIT License
74 stars 30 forks source link

running simple_client_example.py gives an error #280

Closed lhumb closed 8 months ago

lhumb commented 8 months ago

Describe the bug

Running the script simple_client_example.py gives an error

To Reproduce

running: python simple_client_example.py

`Logging in...

Retrieving cars...

Traceback (most recent call last):
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/simple_client_example.py", line 83, in <module>
    loop.run_until_complete(get_information())
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/simple_client_example.py", line 49, in get_information
    await car.update()
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/models/vehicle.py", line 113, in update
    for name, data in await responses:
                      ^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/models/vehicle.py", line 107, in parallel_wrapper
    r = await function()
        ^^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/api.py", line 114, in get_remote_status_endpoint
    return await self._request_and_parse(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/api.py", line 49, in _request_and_parse
    return model(**response)
           ^^^^^^^^^^^^^^^^^
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 4 validation errors for RemoteStatusResponseModel
payload -> telemetry -> fugage -> unit
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> fugage -> value
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> rage -> unit
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> rage -> value
  none is not an allowed value (type=type_error.none.not_allowed)`

Expected behavior

The script should output

CM000n commented 8 months ago

Thx for reporting 😊 Seems we have to adjust our pydantic RemoteStatusResponseModel here.

Can you give us some more information? Which car and fuel type are you using?

lhumb commented 8 months ago

Oh yes – it is a bz4x, a full electric car – you already reported, that those cars have no fuel ;-) #278

lhumb commented 8 months ago

eXcuse, but after git pull and reading your log entry, I run python simple_client_example.py again but the output is the same as above…

…
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__

pydantic.error_wrappers.ValidationError: 4 validation errors for RemoteStatusResponseModel
payload -> telemetry -> fugage -> unit
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> fugage -> value
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> rage -> unit
  none is not an allowed value (type=type_error.none.not_allowed)
payload -> telemetry -> rage -> value
  none is not an allowed value (type=type_error.none.not_allowed)
lhumb commented 8 months ago

after last commit; 66ad51ed2db1094ae1b109913b74e8afbdde312f your one: https://github.com/DurgNomis-drol/mytoyota/pull/286 it seems that this »solution« is incomplete

$ python simple_client_example.py 
Logging in...
Retrieving cars...
Traceback (most recent call last):
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/simple_client_example.py", line 83, in <module>
    loop.run_until_complete(get_information())
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/simple_client_example.py", line 49, in get_information
    await car.update()
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/models/vehicle.py", line 113, in update
    for name, data in await responses:
                      ^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/models/vehicle.py", line 107, in parallel_wrapper
    r = await function()
        ^^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/api.py", line 155, in get_telemetry_endpoint
    return await self._request_and_parse(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/oldroot/home/humbert/dokumente/photovoltaik-wallbox/mytoyota/mytoyota/api.py", line 49, in _request_and_parse
    return model(**response)
           ^^^^^^^^^^^^^^^^^
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for TelemetryResponseModel
payload -> fuelLevel
  field required (type=value_error.missing)
CM000n commented 8 months ago

This is not "incomplete", this is just another issue with another model :wink:

lhumb commented 8 months ago

OK ;-)

CM000n commented 8 months ago

None of us current developers have a bz4x and there is no official documentation for the API. So all we can do is trial and error. 😞

lhumb commented 8 months ago

If you are able to tell me, how I can help, pls…

CM000n commented 8 months ago

You're already doing that. 😉 Simply testing extensively and creating issues for things you notice already helps us. 😊

But for better tracking, please try to create a separate issue for each problem and not write everything in this issue or summarize problems in one issue.