Open dahlb opened 2 years ago
I also checked in a simple stub file for each region/brand to generate responses if you want to checkout the repo instead
@rappazzo it would be great if you could contribute some sample responses here to harden up the uses of this implementation for the community
There's an error somewhere in there
Traceback (most recent call last):
File "kia_hyundai_api/src/kia_hyundai_api/us_hyundai_stub.py", line 33, in <module>
asyncio.run(testing())
File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "kia_hyundai_api/src/kia_hyundai_api/us_hyundai_stub.py", line 26, in testing
access_token, = await api.login(username=username, password=password, pin=pin)
File "kia_hyundai_api/src/kia_hyundai_api/us_hyundai.py", line 154, in login
response_json = await response.json()
AttributeError: 'NoneType' object has no attribute 'json'
I did adjust the stub to get the credentials interactively, so the line numbers won't be the same.
@rappazzo thanks a lot for testing it out, I found the first US Hyundai error https://github.com/dahlb/kia_hyundai_api/blob/master/src/kia_hyundai_api/us_hyundai.py#L44, I was only checking the error case when I ran it I fixed the stubs logging and aiohttp cleanups, look forward to that interactive version if you can include that in your PR :)
Traceback (most recent call last):
File "src/kia_hyundai_api/us_hyundai_stub.py", line 36, in <module>
asyncio.run(testing())
File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "src/kia_hyundai_api/us_hyundai_stub.py", line 27, in testing
access_token, = await api.login(username=username, password=password, pin=pin)
File "src/kia_hyundai_api/us_hyundai.py", line 162, in login
expires_in = float(response["expires_in"])
TypeError: 'ClientResponse' object is not subscriptable
Authentication seemed to work though
@rappazzo sorry for what feels like the second dunce mistake on my part. I fixed it here https://github.com/dahlb/kia_hyundai_api/commit/cb1f9936ade41a6b169068632fb2fb07fdc6ad67#diff-29e75d022b3edafdec384ced521a8176a2c3db83508de1639c92230be46e51d9R162 and cleaned up some other things after a full visual walk through. I hope that was the last error, I also added in the lock command for an example of an action api call. If you don't mind adding the response headers from the logs here too could be very helpful. Currently US Hyundai is the only api that doesn't track the status of the actions asynchronously but the response headers, particularly the lock's response headers could offer clues to tracking it.
I've finally had time to rerun this, and it does work. Here are my scrubbed results: us-hyundai-response.json.txt
Here is a diff of the changes that I made to that file to ask for the password: usa_kia_api.diff.txt
I did notice that the password was printed in the output in plain text, so you should probably clean that up.
@rappazzo thanks I added that response to the get vehicles documentation and incorporated the user input into the stub files. I also sanitized the logs to try and prevent sensitive details from entering the logs. if you have the responses from the other api calls in the stub, get_cached_vehicle_status/get_location/lock it would be great to add those also, for lock if you can include the response headers that would be great as it might shed light on a feature us hyundai is missing that other regions/brands already have.
from a python console run
but with real username, password, and PIN. the console should show all the responses raw json; if you can post the responses I'll add them to the API files for reference like I did for the us kia version https://github.com/dahlb/kia_hyundai_api/blob/master/src/kia_hyundai_api/us_kia.py#L140
BE SURE TO REMOVE ANY PII like vin, but I'm not sure which PII will be in the responses, you could email it to me at dahl.brendan@gmail.com if you want a second pair of eyes to check for PII before it's online. Feel free to add the documentation in a PR if you'd like :).