paulw11 / homebridge-elkm1

Homebridge plugin for the Elk M1 alarm panel
MIT License
7 stars 6 forks source link

timeout #1

Closed politics123 closed 7 years ago

politics123 commented 7 years ago

Hey --

Was playing with this, glad someone started a project. I'm getting an unhandled exception due to timeout:

[6/11/2017, 3:00:25 PM] Loaded plugin: homebridge-elkm1 [6/11/2017, 3:00:26 PM] Registering platform 'homebridge-platform-elk.ElkM1' [6/11/2017, 3:00:26 PM] --- [6/11/2017, 3:00:26 PM] Loaded config.json with 0 accessories and 1 platforms. [6/11/2017, 3:00:26 PM] --- [6/11/2017, 3:00:26 PM] Loading 1 platforms... [6/11/2017, 3:00:26 PM] [ElkM1] Initializing ElkM1 platform... [6/11/2017, 3:00:26 PM] [ElkM1] Connection is not secure [6/11/2017, 3:00:26 PM] [ElkM1] Connecting to M1 [6/11/2017, 3:00:26 PM] [ElkM1] Connected (node:3604) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Timout occured before Zone Status Report (zs) was received.

paulw11 commented 7 years ago

Hi. This is caused by this issue in the elkmon module that is used inside homebridge-elkm1.

I have been able to work around it by editing my local copy of elkmon's index.js. You need to look for the following code block:

getDescription(id: number, type: TextDescriptionType, cb) {
    //Listen for response
    this.once('SD', (response) => {
      cb(response);
    });

    //Send the command
    let elk = new ElkMessage(`sd${leftPad(type.toString(), 2, 0)}${leftPad(id.toString(), 3, 0)}`, null);
    this.connection.write(`${elk.message}\r\n`);

    //Setup timeout
    setTimeout(function () {
      cb({ error: 'Timout occured before Text Description (sd) was received.'});
    }, 2000);
  }

and change the 2000 to a larger number; I found 15000 worked for me.