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

Homekit helpers - target position and opening/closing state #79

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andersonshatch
Copy link
Owner

Will address #76
@markob100 would appreciate your feedback on this after some testing.

@markob100
Copy link

markob100 commented Aug 30, 2019 via email

@andersonshatch andersonshatch force-pushed the homekit-helpers branch 2 times, most recently from 1387999 to 50bd740 Compare August 30, 2019 17:38
@markob100
Copy link

I've had this running for a few days. Stable, but doesn't seem to add the enhancement.

targetPosition

Expected: targetPosition (as displayed on the JSON generated by the GET command) to change immediately on receipt of POST 'move to x' command to 'x'.
What happens: both targetPosition and Position stay at initial position until blind has settled at 'x'.
Example: Blind was at 100. I sent POST command to move to 47. Blind started moving. Both tP and P stayed at 100 (looking at it both in the repeatedly-refreshed browser window and in HK which pulls the data from the webpage JSON) until blind had stopped moving at 47, then both tP and P updated simultaneously to 57.

state
Expected: state (as displayed on the JSON generated by the GET command) to change to 'opening' or 'closing' (as appropriate) when blind is moving from Position to targetPosition. Then to read 'open' if Position is not 0, and to read 'closed' is Position is 0 (existing behaviour).
What happens: State doesn’t seem to change from ‘open’ - I don’t see ‘opening’ or ‘closing’ in the JSON when the blind is moving.

Am I missing something obvious? I've definitely got the right branch installed - I do see 'targetPosition' in the JSON, it just seems to match Position at all times.

Thanks for your work on this - much appreciated, and this is already much more functional than SomaConnect!

@andersonshatch
Copy link
Owner Author

I think there was essentially a race sometimes between whether you'd get the targetPosition of what you requested, or the one from the previous state. And state opening/closing I was not changing until the callback from the BTLE write succeeded, so it was definitely after the state is retrieved to be returned with the POST.

I've now moved these to happen earlier, which means they're set on the assumption that the state write succeeds (no error with BTLE comms); sometimes this will not be true, but you should at least see the states more frequently this way. LMK how it looks! :)

@markob100
Copy link

markob100 commented Sep 8, 2019 via email

@andersonshatch
Copy link
Owner Author

andersonshatch commented Sep 8, 2019 via email

@markob100
Copy link

markob100 commented Sep 11, 2019 via email

@markob100
Copy link

@andersonshatch any thoughts on the above? Question is 'What’s the downside of ‘restoring’ on reconnect?'

@andersonshatch
Copy link
Owner Author

andersonshatch commented Sep 18, 2019

Haven't had a chance to verify this yet, but I think there will be an issue if the opening/closing state is restored on reconnect, but in fact, the device has already stopped moving.

This is down to the current position characteristic -- which I subscribe to and read on (re-)connect -- only getting updated when the device stops moving.
Whilst it is moving to the target position, we hear nothing from the device, so can only infer that it's stopped moving if there was no reconnect when we next get a current position value.

I think there could be a workaround for that, which is if we're in opening/closing state, check when we get a value for current position and switch to open/closed if it is equal to the target position (or within a few points of it, as sometimes they'll stop before reaching the target position)

Hopefully can verify this in the not too distant future.

@markob100
Copy link

markob100 commented Sep 20, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants