TreehouseFalcon / homebridge-kwikset-halo

An easy to use Homebridge plugin for Kwikset Halo locks
Apache License 2.0
7 stars 2 forks source link

Hook into lock state subscription instead of polling #8

Closed TreehouseFalcon closed 7 months ago

TreehouseFalcon commented 7 months ago

The plugin's current method of retrieving locked/unlocked status is through polling Kwikset's API on an interval. This should be investigated and changed to use the same method the Kwikset mobile app uses to send push notifications.

jgstroud commented 7 months ago

I'm not sure how to do this, but I was looking at the current implementation, and I refactored a few things and changed it to use async polling at 30 second intervals. The Home Assistant plugin also polls at 30s intervals. It seems more responsive now. I'll submit a PR and you can give it a try.

jgstroud commented 7 months ago

Also, I should point out, I am by no means any kind of expert here. I've hacked together another HB plugin, which was my first exposure to typescript and I've hacked on a few other plugins.

TreehouseFalcon commented 7 months ago

I'm going to research the idea of hooking straight into the subscription the Android app is using a bit more, but I can't guarantee anything quite yet. My parents have had issues with their lock battery dying rather quickly and I suspect it might be because Kwikset pings the lock itself to get an updated state. Seems excessive.

jgstroud commented 7 months ago

I monitored all the traffic to and from the lock and can confirm that polling the API does not trigger any additional traffic to or from the lock itself and should have no impact on battery life.

If your lock batteries are dying quickly, you might just check that there is no friction on the bolt and that it turns easily and freely. Sometime misalignment can cause the bolt to rub on the jamb or it can also bind internally.

TreehouseFalcon commented 7 months ago

Thanks for looking into that! Good to know the plugin isn't affecting battery life. I think in that case I'll close this issue for now.

jgstroud commented 7 months ago

Well, don't get me wrong, it would be really cool if you can figure out how to do it. But maybe not critical.