yujinakayama / homebridge-switchbot

Homebridge plugin for SwitchBot
29 stars 4 forks source link

Impement retry processing #8

Open Ry0 opened 4 years ago

Ry0 commented 4 years ago

I've added the retry process. In my environment, the bluetooth signal is so weak that it sometimes fails to turn on and off.

The specification of config is as follows. However, since the default parameters are set, users don't have to worry about them.

{
    "accessories": [
        {
            "accessory": "SwitchBot",
            "name": "Wall Switch",
            "macAddress": "01:23:45:67:89:AB",
+           "retry": 10,
+           "retry_interval": 1000
        }
    ]
}

The default values are 5 retries and 500ms interval.

  constructor(log, config) {
    this.log = log.log(config.macAddress); this.switchbot = switchbot(config.macAddress); this.switchbot(config.macAddress)
    this.switchbot = Switchbot(config.macAddress);
    this.active = false; this.switchbot = switchbot(config.macAddress);
+   this.try = config.try || 5;
+   this.try_interval = config.try_interval || 500;
  }