cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 38 forks source link

Problem when homekit updates two or more identical characteristics on different accessories at the same time #21

Closed grsir closed 7 years ago

grsir commented 7 years ago

Environment:

Symptom:

Cause:

          if (set_timeout && c === pre_c) {
            console.log("clearing timeout...")
            clearTimeout(set_timeout);
          }
          set_timeout = setTimeout(function() {
            console.log("calling Mqtt.set...")
            Mqtt.set(this.name, c, value, callback);
          }.bind(this), 250);
          pre_c = c;

Fix/Workaround: Never cancel the timeout or implement a per accessory timeout.

BTW, that code can also have strange results in some theoretical situation:

cflurin commented 7 years ago

@grsir: Thanks for your feedback, I hope to find time next week for this issue. Otherwise Pull requests are welcome.

cflurin commented 7 years ago

@grsir:

try the github version:

sudo npm install -g cflurin/homebridge-mqtt
grsir commented 7 years ago

@cflurin:

I just made few tests with your fix and everything seems perfect to me.

Thanks!