-
Notifications
You must be signed in to change notification settings - Fork 120
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 check command to POST commands #772
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #772 +/- ##
==========================================
+ Coverage 99.64% 99.65% +0.01%
==========================================
Files 8 8
Lines 1404 1447 +43
==========================================
+ Hits 1399 1442 +43
Misses 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I suppose it would - but it always returns complete with a 908. I'll add a
test to OR 908 with complete.
Good catch :)
…On Mon, Sep 18, 2023 at 8:49 AM Kevin Fronczak ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In blinkpy/api.py
<#772 (comment)>:
> @@ -467,3 +489,20 @@ async def http_post(blink, url, is_retry=False, data=None, json=True, timeout=TI
json_resp=json,
data=data,
)
+
+
+async def wait_for_command(blink, json_data: dict) -> bool:
+ """Wait for command to complete."""
+ _LOGGER.debug("Command Wait %s", json_data)
+ network_id = json_data.get("network_id")
+ command_id = json_data.get("id")
+ if command_id and network_id:
+ while True:
What happens if the status code always returns 908? This will get stuck in
an infinite loop, right?
—
Reply to this email directly, view it on GitHub
<#772 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3GVBFNZXDYWX6EXRI3LXDX3A7OJANCNFSM6AAAAAA42H35NI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
For documentation: Command polled message looks like this: "complete" |
Looking at this a bit further, If the |
Oh completely forgot about this- I think my comments in the other PR relate to this one actually. |
I didn't realize you had a question/suggestion in there :) I agree it makes sense to NOT be stuck if the API behaves poorly. |
Yeah adding an error message or something would make sense at some point, but for now what's there is fine. Can you just remove the |
Now I'm getting things mixed up :) Should be good now. |
Maybe we could do a release on pypi and I'll update the PR over at HA to use it - since it appears to be "stuck", might as well bump it one more time :) |
Yeah good idea, I'll do that shortly |
Description:
While researching the event API, I discovered the Android app polls the command status to determine when to get the results. This improves the performance quite a bit as we don't have to wait for the last backoff (some times 24 seconds).
All POST methods receive a response code with the command id and network id. Polling at 1 second (same as the app) until it receives a complete.
If any of the keys are missing, the API will fall back to the previous retry method.
Related issue (if applicable): fixes #
Checklist:
tox
run successfully PR cannot be meged unless tests pass