bryan-bartow / homebridge-alarm.com

Alarm.com plugin for Homebridge
ISC License
43 stars 11 forks source link

Add Locks & Caching #15

Closed yungsters closed 8 years ago

yungsters commented 8 years ago

Adds support for controlling locks associated with an Alarm.com account to the plugin.

This also adds some primitive caching of the session (with a 60s timer) and responses (locks with a TTL of 5s) which should make most HomeKit user interfaces significantly more responsive.

Fixes #10 and partially addresses #13.

yungsters commented 8 years ago

@bryanbartow Since you do not have any locks, can you try testing this to make sure I have not broken anything for users without locks?

yungsters commented 8 years ago

I've included a couple commits that implement caching. If GitHub were a better platform, I'd be able to propose these changes in a separate and dependent pull request. But unfortunately, a bloated pull request is all we have to work with. 👎

bryanbartow commented 8 years ago

Seems to me to work fine without locks. I'm merging.

bryanbartow commented 8 years ago

@yungsters I spoke to soon. Although for some reason it worked locally in debug mode, Homebridge is not happy about me not having locks. If I'm reading the code correctly, it looks like it's calling getLockAccessories() on startup when the platform is instantiated. It's expecting the WrapAPI locks call to return the locks object. When it makes that call and doesn't get it, it bombs. Can we make locks conditional? Maybe by adding a property in the config? useLocks: true/false?

yungsters commented 8 years ago

Can you share with me the error that you get? Ideally, the WrapAPI endpoint would simply return an empty array of locks.

bryanbartow commented 8 years ago

@yungsters Listed the error in #16

Error while registering accessories: TypeError: Cannot read property 'map' of undefined