alexryd / homebridge-shelly

Homebridge plugin for Shelly devices
MIT License
299 stars 44 forks source link

Lock Type for Shelly1 #142

Open nitaybz opened 4 years ago

nitaybz commented 4 years ago

First of all thank you for the plugin 🙏 I know it takes a lot of efforts.

Please create a "lock" type for the shelly1 as i'm using it for intercom gate opener. I would really appreciate it :)

jsiegenthaler commented 4 years ago

I too would like this

jsiegenthaler commented 4 years ago

I just installed my Shelly1 to activate my front door lock. Can you please add a Lock type?

alexryd commented 4 years ago

How are you using the Shelly 1 to control your lock? Is the lock connected to the switch input or otherwise on the Shelly 1 so that you can tell if the lock is actually secured or not?

jsiegenthaler commented 4 years ago

Hi. I live in an apartment, with an intercom that has a "DOOR" push-button. When the DOOR button is pressed , the building front door is unlocked (electric door lock which makes a loud buzzing noise). The door stays unlocked for the duration the button is pressed.

The Shelly1 relay connects across the DOOR switch on the intercom. I set the Shelly1 to automatically turn off after 8 seconds, this is configured inside the Shelly1 using the Shelly web GUI.

I issue a "Hey Siri Unlock the Front Door" command, and Siri sets the LockMechanism accessory to Unlock. An small automation connects the LockMechanism to the Shelly1 switch (named "Door Opener", and turns on the Switch (thus closing the relay, and activating the door lock to allow the door to be opened). After the predefined 8 seconds auto-off, the Shelly1 turns off, and the "Door Opener" Switch goes off in Homekit. A second small automation is then triggered and changes the LockMechanism to Locked to show that the door as locked. (whether it actually physically is locked or not cannot be determined).

Thus I only have two states: State 1: Door Locked (Shelly1 relay off) State 2: Door Unlocked (Shelly1 relay on) There's no transition status, no jammed status, no verification that the door is actually open, opening, closed, closing, locked or unlocked. But that's all I need. If I wanted actual door status, I'd need to connect a Homekit door sensor, or power the Shelly1 from 12V and use a magnet & reed switch on the Shelly1 SW input.

If you added a type = LockMechanism, supporting Locked (relay off, the default unpowered state) and Unlocked (relay on, powered) states, then I wouldn't need the automation, thus making Homekit faster and more reliable.

You could also add an inverted=true to invert the logic to make it flexible for other situations where the Relay On means locked instead of unlocked.

And, if you wanted, you could add a second contact sensor on the same LockMechanism device based on the SW input. I wouldn't use it myself, but other people might.

Happy to beta test for you ;)

fsargent commented 3 years ago

For me the only request is that it looks like a "lock" not a "switch" in the UI. Also, I think it being a lock will allow me to ask Siri to "Open the gate" not "Turn on the gate" which is what's required, despite it making no sense.

andyblac commented 3 years ago

sorry please ignore privous post, wrong git my bad.

nitaybz commented 2 years ago

please make it happen 🙏