dxdc / homebridge-blinds

:sunrise: Homebridge Plugin to control my blinds over HTTP
https://www.npmjs.com/package/homebridge-blinds
ISC License
54 stars 26 forks source link

Refactor opening/closing logic; persist state #22

Closed dxdc closed 4 years ago

dxdc commented 4 years ago

Made a number of changes and improvements:

dxdc commented 4 years ago

@zwerch I made some additional edits here which I'm very pleased with.

What I realized is that the blind% was not being accounted for properly because of response delays (in my case) between the server command and the blind movement. In the case where an additional stop request is needed, that is actually another delay and the target% will overshoot.

To deal with this, I've made the following additional changes:

This is not going to be perfect (e.g., when changing from 41% to 45%) but it should be fairly accurate for major changes.

I also discovered that there is no need to set PositionState; HomeKit handles this for us using CurrentPosition and TargetPosition.

Would appreciate your review! And, thanks for creating this plugin.