kpsuperplane / homebridge-wiz-lan

Control Wiz lights over LAN
Apache License 2.0
115 stars 37 forks source link

Loading from cache funciton does not refresh for removed bulbs #60

Closed Lazybeez closed 3 years ago

Lazybeez commented 3 years ago

When bulbs are removed physically, the plugin still tries to load bulb from cache leaving unresponsive bulbs

https://github.com/kpsuperplane/homebridge-wiz-lan/blob/c34da79a207b52df747a6bd02d68b83c51c657f1/src/wiz.ts#L40 https://github.com/kpsuperplane/homebridge-wiz-lan/blob/c34da79a207b52df747a6bd02d68b83c51c657f1/src/wiz.ts#L82 https://github.com/kpsuperplane/homebridge-wiz-lan/blob/c34da79a207b52df747a6bd02d68b83c51c657f1/src/wiz.ts#L126

Lazybeez commented 3 years ago

will look into the details later

Lazybeez commented 3 years ago

for now it will not result in any issue other than leaving an unresponsive bulb. however this is potentially dangerous as it is trying to update a non-existing bulb

Unhandled error thrown inside write handler for characteristic: Cannot read property 'state' of undefined

Lazybeez commented 3 years ago

Solution: initAccessory should have returned an boolean value indicate whether the bulb is initialized successfully And only load those that has been initialized successfully Further maybe clean up automatically or give user an option to clean up on load

im not familiar with the language, but I can try open a fix PR later

Lazybeez commented 3 years ago

sry about the messy info looks like the cache reloading part is being handled by homebridge. not sure if it still a plugin level fix

Lazybeez commented 3 years ago

closed as it's very likely Hoobs specific cache issue