-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Fixed method handleUpdatePlatformAccessories() #3765
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
Fixed method handleUpdatePlatformAccessories() #3765
Conversation
Pull Request Test Coverage Report for Build 12845094518Details
💛 - Coveralls |
* Fixed method handleUpdatePlatformAccessories() * Fixed filter matching condition and removed lint annotation
* Fixed method handleUpdatePlatformAccessories() * Fixed filter matching condition and removed lint annotation
I think this has caused #3773 |
Line 203 in b156845
I wonder if part of the issue is that in homebridge-lib it is passing undefined rather than an empty array. We could fix the homebridge code to check for the existence of a passed array. changing the type to optional. I guess this new issue never presented itself before because the argument was never being used, whether any value was passed in or not. |
The bug is in homebridge-lib, as it is calling updatePlatformAccessories() with the wrong parameters. Up until now it has been masked by the bug in Homebridge code. Homebridge should not be "coding to the bugs". The reason that I recommend against modifying Homebridge code is, consider a scenario where someone removed from this decision decides to reimplement this method. This will end up breaking homebridge-lib anyway. The fact that the code fix is in a beta, means that a Homebridge release could wait until a fixed version of homebridge-lib was released. However adding some defensive code would not be a bad idea:
|
Fix bug that manifested in Homebridge 2.0 beta, see homebridge/homebridge#3765, homebridge/homebridge#3773, and ebaauw/homebridge-ups#26.
Passing an empty array seems to work, thanks. For truly defensive code, you would need to check that the |
I can't speak about Javascript, as I have limited experience, but in Typescript you cannot call |
@ebaauw after another thought on this situation it made me wonder what your intentions were with these lines
because even before or after the changes in this PR, it seems to me that it isn't doing anything?
If an empty array is passed in:
perhaps I am missing something? or what you are aiming to do isn't actually happening? |
I want to force-write
Couldn't agree more. I started with Homebridge way before TypeScript, so all my plugins (still) are plain JavaScript. I might want to change that to TypeScript, someday, but I rather spend my time on functional enhancements than a technical refactor. Homebridge might very well be obsoleted by Matter, before I'll find the time. |
Do you store the accessory's state in the context? I have accessories with persistent state (on/off, open/close) and I store that in a json file, and handle writing, reading, and deletion. And after reading your statement, a lightbulb just went off and I'm feeling like a complete donkey 🤣 |
That's what the |
- Added method updateDisplayName() (#3764) (@justjam2013) - Fixed method handleUpdatePlatformAccessories() (#3765) (@justjam2013) - Make it possible to set Characteristic.SerialNumber via config.json (#3761) (@Vvorcun) - minor dependency updates - fix: check for valid array in `handleUpdatePlatformAccessories` - minor dependency updates - `hap-nodejs` @ `v0.12.3`
* Fixed method handleUpdatePlatformAccessories() * Fixed filter matching condition and removed lint annotation
- Added method updateDisplayName() (#3764) (@justjam2013) - Fixed method handleUpdatePlatformAccessories() (#3765) (@justjam2013) - Make it possible to set Characteristic.SerialNumber via config.json (#3761) (@Vvorcun) - minor dependency updates - fix: check for valid array in `handleUpdatePlatformAccessories` - minor dependency updates - `hap-nodejs` @ `v0.12.3`
♻️ Current situation
The method handleUpdatePlatformAccessories() is not properly implemented. In this method, the array of PlatformAccessory objects is lost, as it is not used in the handleUpdatePlatformAccessories() method. The method just saves the currently cached platform accessories back to disc without updating anything.
See Updating Platform Accessories does nothing - method is not implemented.
💡 Proposed solution
⚙️ Release Notes
➕ Additional Information
Testing
Reviewer Nudging