sammy1881 / homebridge-sengled-bulbs

Homebridge plug-in for Sengled zigged bulbs
2 stars 4 forks source link

Fix context state On upgrade Issue. Add login/timeout config. Fix device rename and missing. #11

Closed RandyTidd closed 2 years ago

RandyTidd commented 2 years ago

This change defers creation of SengledLightAccessory instances until the didFinishLaunching callback, after context data has been updated from the Sengled client. This should resolve crashes on updates where context data is changed, but the homebridge cached accessory still has the old version.

A timeout and alternate login api option is added. The timeout appears as a slider in the homebridge plugin settings, and the alternate login URL shows up as a checkmark. Defaults are to keep the same behavior as before this change. The alternate login URL required removing the baseURL and updating all URLs to be full paths. The existing sengled login API stopped working for me during development of this change, so I needed to add this to keep the sengled api working for me.

While testing, discovered that the change that introduced the context data upgrade issue also regressed device rename handling, this change also fixes that. Some fixes for potential issues when Sengled API reports no devices. getDevices should always return a valid object. Simplified removal of accessories that are registered, but no longer reported by the sengled API.

Change SengledLightAccessory to use updateValue during initialization to update context data from Sengled API instead of invoking callbacks via getValue.

Rev'd the package.json.

RandyTidd commented 2 years ago

I'm having a problem with multiple listeners being registered that I need to figure out first.