title: Changing Philips Hue Brightness with a UISlider Objective C
body: <p>I am building an app that controls three philips hue RGB LED bulbs. I want to be able to change the brightness using the UISlider.  Currently I have a UISlider that calls a method upon each change, however, this method far exceeds the philips hue bridge's 10 commands per second limitation. Here is the method I call upon a change in the UI slider.</p>
  
  <pre><code>- (void) changeBulbBrightness: (NSNumber *)currentBrightness
  {
      NSTimeInterval timeInterval = [self.timeLastCommandSent timeIntervalSinceNow];
      NSLog(@"Time Since Last command: %f", timeInterval);
      if (timeInterval &lt; -0.3)
      {
          NSLog(@"COMMAND SENT!!!!");
          PHBridgeResourcesCache *cache = [PHBridgeResourcesReader readBridgeResourcesCache];
          PHBridgeSendAPI *bridgeSendAPI = [[PHBridgeSendAPI alloc] init];
          for (PHLight *light in cache.lights.allValues)
          {
              PHLightState *lightState = light.lightState;
              //PHLightState *lightState = [[PHLightState alloc] init];
              if (lightState.on)
              {
                  [lightState setBrightness:currentBrightness];
                  // Send lightstate to light
  
  
       [bridgeSendAPI updateLightStateForId:light.identifier withLightState:lightState completionHandler:^(NSArray *errors) {
                  /*if (errors != nil) {
                      NSString *message = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"Errors", @""), errors != nil ? errors : NSLocalizedString(@"none", @"")];
                      if (self.loggingOn)
                      {
                          NSLog(@"Brightness Change Response: %@",message);
                      }
                  }
                   */
              }];
          }
          self.timeLastCommandSent = [[NSDate alloc]init];
      }
  }
  self.appDelegate.currentSetup.brightnessSetting = currentBrightness;
  NSLog(@"Brightness Now = %@", currentBrightness);
  </code></pre>
  
  <p>I've tried making a timer to limit the amount of commands to 10 per second but the bridge still acts the same way it does when it is overwhelmed with commands (stops acceptance of all commands).  Any help or direction would be greatly appreciated.  Thanks in advance!</p>