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:
In the prior change that introduced issue #8 I also regressed accessory renamed, this is fixed. Also added GetDeviceName function so that accessory creation and check for rename used the same logic to determine name.
In homebridge debug mode, I saw the warning: "Characteristic 'On': SET handler returned write response value, though the characteristic doesn't support write response." The issue was that the callback for the set handler was returning a value, but shouldn't have.
Added a catch handler to device discovery. When this timed out it was throwing an unhandled error to homebridge.
getHue() debug logging showed undefined for accessory name. Fixed with gitName() method.
Removed some redundant whole accessory logging.
Changed homebridge state updates to use updateValue instead of getValue. The latter invokes the onGet callback while the former just sets the state directly.
Removed sengled API state checking in the On characteristic get handler due to timeouts or warnings from homebridge that we are slowing homebridge down. Toggling the light corrects the state if it's modified by an outside source, and periodic device discovery will also correct it.
Fixed the second logging instance in setColorTemperature to report the sengled color temperature value that is actually sent to the API. The first already logs the mired value set by homebridge.
Added some handling for the case that device discovery reports no devices.
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: