question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lock Accessory for Door-buzzer

See original GitHub issue

Hi,

I’m trying to modify the standard Lock Accessory to control my apartment’s Door-buzzer. I hooked up the buzz-unlock-mechanics to an Arduino, and the Arduino is hooked up to a Relay which connects 2 wires for opening the door.

In this situation the door does not have an actual Secured and Unsecured reading. Thats because once the two wires have been connected, the door can be pushed open, and when the door falls shut again, you guessed it… it’s locked again.

So what I was thinking; once I’ve executed the unlock command, the door should unlock (UNSECURED) for 2 seconds and after those two seconds, it the lock should automatically reset it’s status back to the SECURED state again.

I’ve tried all sorts of code modifications but I could not get it to work.

Can you please point me in the right direction?

Thank you very much!!

Cheers!

Something I’ve tried as an example:

if (value == Characteristic.LockTargetState.UNSECURED) {
      FRONT_DOOR_LOCK.unlock();

      // now we want to set our lock's "actual state" to be unsecured so it shows as unlocked in iOS apps
      lock
        .getService(Service.LockMechanism)
        .setCharacteristic(Characteristic.LockCurrentState, Characteristic.LockCurrentState.UNSECURED);

      FRONT_DOOR_LOCK.lock();      
      // now we want to set our lock's "actual state" to be locked so it shows as open in iOS apps

      lock
        .getService(Service.LockMechanism)
        .setCharacteristic(Characteristic.LockCurrentState, Characteristic.LockCurrentState.SECURED);

      callback(); // Our fake Lock is synchronous - this value has been successfully set
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marcelkordekcommented, Aug 20, 2016

Hi, this is my final Solution:

LockAccessory.prototype.setState = function(state, callback) {
  var lockState = (state == Characteristic.LockTargetState.SECURED) ? "lock" : "unlock";
  var update = (state == Characteristic.LockTargetState.SECURED) ? true : false;

  this.log("Set state to %s", lockState);

  request.get({
    url: this.url,
    qs: { option: "setState", apiKey: this.apiKey, lockid: this.lockID, delay: this.delay, state: lockState }
  }, function(err, response, body) {

    if (!err && response.statusCode == 200) {
      this.log("State change complete.");

      // we succeeded, so update the "current" state as well
      var currentState = (state == Characteristic.LockTargetState.SECURED) ?
        Characteristic.LockCurrentState.SECURED : Characteristic.LockCurrentState.UNSECURED;

      lockservice
        .setCharacteristic(Characteristic.LockCurrentState, currentState);

    if(!update){
      setTimeout(function(){
        lockservice
        .setCharacteristic(Characteristic.LockTargetState, Characteristic.LockTargetState.SECURED);
        update = true;  
      }, this.delay);
    }

      callback(null, state); // success
    }
    else {
      this.log("Error setting state (status code %s): %s", response.statusCode, err);
      callback(err || new Error("Error setting lock state."));
    }
  }.bind(this));
},

Everything works like expected. I hope this helps you further.

0reactions
davidhusselmanncommented, Jul 29, 2018

In case this helps anyone, I have hacked my way around this by editing LockMechanism.js and removing the call to set initial to false. This has the effect of always setting the LockTargetState to the real lock state, and IOS doesn’t show “Locking” for me anymore if I open my lock by hand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

wireless door buzzer entry systems - Amazon.com
Amazon.com: wireless door buzzer entry systems. ... UHPPOTE Access Control Electric Strike Door Lock Fail-Secure Kit System with Remote Control.
Read more >
Locking Accessories - maglocks secure locking equipment
Locking hardware equipment, components, parts and accessories from maglocks. ... JBS-2 Audio Buzzer Module for 600 series magnetic locks. $64.33 $75.68.
Read more >
ONLY 2 WIRES! MAGNETIC DOOR LOCK KIT, buzzer, ...
MAGNETIC DOOR LOCK KIT, buzzer, remote control, Exit Button, delay at the best online prices at eBay! Free shipping for many products!
Read more >
Door Accessories - Strikes/Bells/Buzzers/Pushbuttons
Home · Door Accessories; Strikes/Bells/Buzzers/Pushbuttons. Strikes/Bells/Buzzers/Pushbuttons. Shop By Price. $0.00 - $63.00 · $63.00 - $107.00 ...
Read more >
Alarm Door Lock - Car Electronics - AliExpress
Suitable for remote door lock, security and antitheft doors. In AliExpress, you can also find other good deals on automobiles, parts and accessories,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found