cflurin / homebridge-mqtt

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

update homekit UI when event happens outside homekit #15

Closed anthonywebb closed 7 years ago

anthonywebb commented 7 years ago

I've been hunting through your code to figure out how you ended up getting around the issue where someone changes state, but not from within the homekit UI (say someone presses a button on the wall). Right now all is well with my plugin so long as everyone uses homekit to toggle the lights, once a wall button is pressed everything is out of sync. My code (for CBus) very closely models this plugin https://github.com/YahavGB/homebridge-mox

cflurin commented 7 years ago

have a look here: https://github.com/cflurin/homebridge-mqtt/blob/master/lib/accessory.js

Accessory.prototype.save_and_setValue

and here: https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/Characteristic.js

 * @event 'set' => function(newValue, callback(err), context) { }
 *        Emitted when someone calls setValue() on this Characteristic with a desired new value. If there
 *        are any listeners to this event, one of them MUST call the callback in order for this.value to
 *        actually be set. The `context` object is whatever was passed in by the initiator of this change
 *        (for instance, whomever called `setValue`).