sammy1881 / homebridge-sengled-bulbs

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

Fix crash on upgrade. Add alternate login. Other fixes #12

Closed RandyTidd closed 2 years ago

RandyTidd commented 2 years ago

This PR resolves [new version crashing homebridge v0.0.4 #8](https://github.com/sammy1881/homebridge-sengled-bulbs/issues/8]. The main issue was that context data was read during configureAccessory, but homebridge may be restoring a cached accessory from a previous version that didn't have the new properties. This change resolves this issue by separating SengledLightAccessory into two steps, construction and BindAndUpdateAccessory. The former sets basic properties, while the latter is responsible for one time initialization of the service and characteristics and updating state with the latest information from Sengled APi's. A previous attempt at this fix had an issue that bound multiple listeners to each characteristic during the timeout for device discovery. That has been resolved in this PR.

Additionally, this PR adds an off-by-default option for an alternate login API. The current login API started timing out for me, even with timeouts as high as 20,000 ms. This option also adds a slider for the timeout of the axios api.

Other issues fixed: