New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remember listeners on AccessoryInformation if returned by getServices #2169
Conversation
if `getServices` returns a Service.AccessoryInformation instance, the existing code copies the `value` but not the `listeners`. In some cases (e.g., in https://github.com/homespun/homebridge-accessory-apcupsd), it isn't "convenient" to retrieve model and serial number information synchronously (cf., #697) . The proposed code copies any listeners in the returned Service.AccessoryInformation instance so as to defer binding of the value until "convenient" Enjoy!
Prepare for possible merge of homebridge/homebridge#2169 Add apcupsd tutorial to README
Name, Model, Manufacurer and SerialNumber must be persistent during the lifetime of the accessory. (by spec) |
var srcCharacteristic = srcService.getCharacteristic(characteristicUUID); | ||
var dstCharacteristic = dstService.getCharacteristic(characteristicUUID); | ||
|
||
if (!srcCharacteristic) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always return false, as "getCharacteristic" will create the characteristic if it is not present.
This PR was pretty much replaced by #2472 But we could adopt the way listeners get replaced. But maybe we should add the code doing the replacements to hap-nodejs? So we can better track any possible changes made to event types. |
I don't think that's entirely true. We might need to update this PR based on the changes in #2472 to match the new generic way of looping through all the services but the UUID one. |
closing in favor of #2476 |
if
getServices
returns a Service.AccessoryInformation instance, the existing code copies thevalue
but not thelisteners
. In some cases (e.g., in https://github.com/homespun/homebridge-accessory-apcupsd/blob/master/index.js#L344), it isn't "convenient" to retrieve model and serial number information synchronously (cf., #697) .The proposed code copies any listeners in the returned Service.AccessoryInformation instance so as to defer binding of the value until "convenient"
Enjoy!