ptz0n / homebridge-verisure

 Platform plugin for Homebridge allowing to manage and control Verisure devices.
https://www.npmjs.com/package/homebridge-verisure
MIT License
66 stars 15 forks source link

Possibility to change auto lock status on/off with a switch #44

Closed tuomaslaa closed 5 years ago

tuomaslaa commented 5 years ago

It would be nice feature to to disable / enable auto locking of the Yale doorman smart lock via HomeKit switch. This is doable via Verisure API.

ptz0n commented 5 years ago

I see, how would you like this feature to be controlled? Would it make sense to set it up as a switch, like a SmartPlug?

Can you provide any request/response data to toggle this feature? Please sanitize any credentials.

tuomaslaa commented 5 years ago

Yes like a switch would be great. You can see example code in here (Python). It's get_lock_config and set_lock_config methods: https://github.com/persandstrom/python-verisure/blob/master/verisure/session.py

and the api url is mentioned in here: https://github.com/persandstrom/python-verisure/blob/master/verisure/urls.py

it's: installation(guid) + 'device/' + device_label + '/doorlockconfig'

ptz0n commented 5 years ago

Sounds like a plan but I don't have a door lock so any help with testing a pre-release would be much appreciated.

skegget commented 5 years ago

I can assist with some testing, just let me know what I need to do.

tuomaslaa commented 5 years ago

I can also test before the release

tuomaslaa commented 5 years ago

Any news on this?

ptz0n commented 5 years ago

Thanks for the ping. I have some draft code locally. Wanna spend some time with this tonight 👍

ptz0n commented 5 years ago

I just pushed a rough draft. Please try it out 🚪

Update the plugin globally

$ npm install -g git://github.com/ptz0n/homebridge-verisure#dev

Alt. run it manually

$ git clone https://github.com/ptz0n/homebridge-verisure.git
$ cd homebridge-verisure
$ git checkout dev
$ npm install
$ homebridge -P .
hansherlighed commented 5 years ago

I've tested the function and it seems to work. I can enable and disable the AutoLock function of the lock.

Thx.

ptz0n commented 5 years ago

Thanks for trying it out @hansherlighed. Currently, the switch service is named the same as the door lock it's configuring.

Do you think we should append the service name with "auto lock"? How is this config named in the Verisure mobile application and/or web interface? Please share screenshots, if you feel comfortable.

Suggestion:

SmartLock (Kitchen) Auto lock

hansherlighed commented 5 years ago

I think it would be good to name it something like you suggest. In the Verisure App, the auto lock feature is just a checkbox with the text "Automatic Locking"(the text string is localized to your Iphone language). I would keep the name as short as possible since the name gets cut on the "home" screen where your favorites are shown. The default naming pattern in the Home app on Iphone is: Room Name Device name Status

So in my case on the "Home" page I only see: Entrance Smartlock... On

So perhaps the best name you could give it would be something like "AutoLock (Kitchen)"

ptz0n commented 5 years ago

Thanks again for your in depth suggestion. I really like "Auto-lock (Kitchen)".

ptz0n commented 5 years ago

The new naming of the switch service is now available on the dev branch. Please update & try it out.

tuomaslaa commented 5 years ago

I got this error:

[2019-2-1 18:52:08] [Verisure] Initializing platform accessory 'undefined'...
Feb  1 18:52:08 homebridge homebridge[31089]: [2019-2-1 18:52:08] [Verisure] Error: Accessories must be created with a non-empty displayName.
Feb  1 18:52:08 homebridge homebridge[31089]:     at new Accessory (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:47:27)
Feb  1 18:52:08 homebridge homebridge[31089]:     at Server._createAccessory (/usr/lib/node_modules/homebridge/lib/server.js:426:21)
Feb  1 18:52:08 homebridge homebridge[31089]:     at Server.<anonymous> (/usr/lib/node_modules/homebridge/lib/server.js:394:32)
Feb  1 18:52:08 homebridge homebridge[31089]:     at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:16:19
Feb  1 18:52:08 homebridge homebridge[31089]:     at verisure.getToken.then.then.then (/usr/lib/node_modules/homebridge-verisure/lib/platform.js:90:9)
Feb  1 18:52:08 homebridge homebridge[31089]:     at <anonymous>
Feb  1 18:52:08 homebridge homebridge[31089]:     at process._tickCallback (internal/process/next_tick.js:189:7)
Feb  1 18:52:08 homebridge homebridge[31089]: (node:31089) UnhandledPromiseRejectionWarning: Error: This callback function has already been called by someone else; it can only be called one time.
Feb  1 18:52:08 homebridge homebridge[31089]:     at /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:12:13
Feb  1 18:52:08 homebridge homebridge[31089]:     at verisure.getToken.then.then.then.catch (/usr/lib/node_modules/homebridge-verisure/lib/platform.js:94:9)
Feb  1 18:52:08 homebridge homebridge[31089]:     at <anonymous>
Feb  1 18:52:08 homebridge homebridge[31089]:     at process._tickCallback (internal/process/next_tick.js:189:7)
Feb  1 18:52:08 homebridge homebridge[31089]: (node:31089) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Feb  1 18:52:08 homebridge homebridge[31089]: (node:31089) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
ptz0n commented 5 years ago

Ough, sorry about that one! Should be fixed now. Please update 🔌