peter-murray / node-hue-api

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

ApiError: Problems resolving hue bridges, HTTP error status: 429 #230

Open FJ05 opened 1 year ago

FJ05 commented 1 year ago

When I use the example code shown in the documentations I get this error message: ApiError: Problems resolving hue bridges, HTTP error status: 429

This is the example code:

const v3 = require('node-hue-api').v3;
const LightState = v3.lightStates.LightState;

const USERNAME = User
  // The name of the light we wish to retrieve by name
  , LIGHT_ID = 2
;

v3.discovery.nupnpSearch()
  .then(searchResults => {
    const host = searchResults[0].ipaddress;
    return v3.api.createLocal(host).connect(USERNAME);
  })
  .then(api => {
    // Using a LightState object to build the desired state
    const state = new LightState()
      .on()
      .ct(200)
      .brightness(100)
    ;

    return api.lights.setLightState(LIGHT_ID, state);
  })
  .then(result => {
    console.log(`Light state change was successful? ${result}`);
  })
;

This code worked fine for 5 minutes and then it just stopped working...

peter-murray commented 1 year ago

It is on Hue, they restrict the number of calls coming from an IP address to the cloud endpoint and expect you to cache the results, or use local mDNS discovery.