peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.18k stars 145 forks source link

ChoiceType array crash due to value name #170

Closed danWithAD closed 4 years ago

danWithAD commented 4 years ago

I've run into this simultaneously in local and remote running instance of node-hue-api.

Error log is as follows,

Failed to get a remote connection using existing tokens. ApiError: Value 'allreadytoinstall' is not one of the allowed values [unknown,noupdates,transferring,anyreadytoinstall,allreadtoinstall,installing]

I've temporarily fixed this by adding the following to node_modules/node-hue-api/lib/types/ChoiceType.js


  _convertToType(val) {
    if (this.validValues.indexOf(val) > -1 || val === 'allreadytoinstall') {
      return val;
    } else {
      throw new ApiError(`Value '${val}' is not one of the allowed values [${this.validValues}]`);
    }
  }
peter-murray commented 4 years ago

It appears that hue has added another value to this choice type, https://github.com/peter-murray/node-hue-api/blob/80a6e4490c4955da9e8d934981a073f5efb65f76/lib/model/BridgeConfiguration.js#L31

I will modify the values and give you a pre release to test with later today.

danWithAD commented 4 years ago

Thank you so much!

peter-murray commented 4 years ago

This has been fixed in 5.0.0-alpha.2 which is in the npm registry (or at least it has in my local testing).

Due to this being a fix that will be required in the 4.x releases, I have just released this change in 4.0.6 as well.

@danWithAD please verify when you get a chance

danWithAD commented 4 years ago

@peter-murray I can confirm that in both local and prod pulling the latest version from master repo works!

dtsn commented 4 years ago

@peter-murray did you patch 4.0.6? Just forced an update on 4.0.6 and I don't get the change. Looking at the tag in github it appears to be missing https://github.com/peter-murray/node-hue-api/blob/v4.0.6/lib/model/BridgeConfiguration.js#L36

peter-murray commented 4 years ago

@dtsn Sorry about that, looks like I failed to apply the actual commit for the fix and just cherry-picked two other commits that referenced it 🤦

I have released 4.0.7 with the correct fix in it now, please try pulling that version from the npm registry.

dtsn commented 4 years ago

@peter-murray Works great! Thanks.