-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add lock and unlock functions #190
Add lock and unlock functions #190
Conversation
7cf8697
to
f2f527f
Compare
Please make sure all cli jobs work |
6c8296c
to
5c79f18
Compare
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
==========================================
- Coverage 94.32% 94.26% -0.07%
==========================================
Files 28 30 +2
Lines 1463 1586 +123
==========================================
+ Hits 1380 1495 +115
- Misses 83 91 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
5c79f18
to
e69969f
Compare
unfortunately |
On a second thought, I'll also add tests for the |
e69969f
to
466236a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing 🎉
I can see that you have added other things that are not directly related to lock/unlock feature, please remove these and add these in a separat PR. This will make it easier for me to review your PR.
Have you tested this locally?
b6dc2f5
to
dd90313
Compare
Updated the comments in its own commit. I've tested it on the 2022 Toyota Yaris |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How sure are we what happens, if a Toyota car doesn't support remote lock/unlocking?
Is an exception raised? Which exception is raised? Should the exception be caught by the mytoyota library, and be converted to a specific mytoyota exception?
Would it be an idea that we also add a function that determines if the remote lock/unlock is supported by a car with a specific vin?
dd90313
to
467042f
Compare
467042f
to
d7abfec
Compare
@joro75
Unfortunately, the car I have available supports remote locking, so I have no way to test the API response if it isn't supported. My guess is that some kind of 4XX error will be thrown. Currently, this will be handled like any generic API error, but if you or anyone can test this and let me know the code/response, I can handle this specific case.
I can't think of a way doing this without sending a lock/unlock request, at least through an API call. Nothing in the decompiled app shows the Totyota API can respond with this capability. The only alternative I can think of is to hardcode the list of cars with this capabilities which then needs to be maintained. Thoughts? |
@apmechev Locking a car that doesn't support remote (un)lockMy Toyota probably doesn't support remote (un)lock, as the option is not shown in my MyT app. I will use your code to try to lock it, so we can see if and which error is being raised. Didn't have time yet to do this, but once I do, I will let you know. Method to determine if remote lock is supportedProbably no specific call is present to determine if remote locking is supported. It could be that it is encoded as an available option in one of the other parameters of the After checking your code again, I now realise that the request-id of the lock/unlock call is needed to request the status. This is a further complication, as it thus is probably not possible to request the lock-status without first calling the lock or unlock call. And we can't call lock or unlock, just to check if the remote locking is supported, as this could result in an unwanted lock or unlock operation. Error when impossible to lockDid you also test what happens if you try to lock the car, when it is not possible to lock it? For example because a door or the trunk is still open? Or another example is when the key is inside the car? I can imagine that any error-situation during a lock is represented in the Thanks in advance for all the work you have already done to add this feature. I'm sorry that I'm still asking for additional improvements. |
I have added the exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are really close now 🎉some minor things below
…ota into add-lock-unlock-functions
…ota into add-lock-unlock-functions
In terms of errors when locking, at least in my case, all errors look like the response below. I tested leaving the passenger door open and leaving the keys inside. I would guess that the
As for doing the polling inside the client.lock/unlock functions, I think that's a good idea. I was debating whether to leave it to the user to do the polling, but I don't imagine the user do anything else than poll for the request status to no longer be |
@apmechev I suggest that we have to make a decision now, who is responsible for checking if an error is present during the lock/unlock:
I do have a preference for the second decision, as it allows the user-program to decide if and how the status is checked. Blocking code in a library is also not a good design. What is your opinion? |
This is indeed a downside, the action takes 5-10 seconds to complete, so the library will have to ping multiple times, as well as make the call blocking (so that no
Sounds like a good plan to me, I was already in the process of implementing an |
@apmechev |
@apmechev I hope you understand that I can only approve this PR, if the automated checks and builds are all passing. And there are 4 failing checks at this moment. |
adds is_success, is_error, is_in_progress to the status response which makes it easier to act on request actions
f1d0a0b
to
eb157e3
Compare
Changes have already been incorporated
@apmechev: Many thanks for this improvement! 👍 It took some time to get it finalized and tested, but it is a very good addition to the library! |
@joro75, thanks it was fun! |
Awesome job guys, and a special thanks to you @joro75 for helping it get over the line 🎉 🎂 |
Resolves #119