public static void SetColorTemperature(string name, ushort value)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsColorTemperature == 1 &&
         Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].ColorTemperature != value)
     {
         ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
         tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
         tempControlIntValueObject.Characteristics[0].AID =
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
         tempControlIntValueObject.Characteristics[0].IID =
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceColorTemperatureIID;
         tempControlIntValueObject.Characteristics[0].Value = value;
         var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
         HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
     }
 }
 public static void SetRGB(string name, ushort red, ushort green, ushort blue)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsRGB == 1)
     {
         RGB tempRgb = new RGB((byte)red, (byte)green, (byte)blue);
         HSV tempHsv = HBLightbulbConversion.RGBtoHSV(tempRgb);
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.H)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.H;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceHueIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation != (ushort)tempHsv.S)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation = (ushort)tempHsv.S;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceSaturationIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Saturation;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
         if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue != (ushort)tempHsv.V)
         {
             Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Hue = (ushort)tempHsv.V;
             ControlIntValueObject tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceBrightnessIID;
             tempControlIntValueObject.Characteristics[0].Value = Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
     }
 }
 public static void SetBrightness(string name, ushort value)
 {
     if (Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].SupportsBrightness == 1)
     {
         var newvalue = Math.Round(value / 655.35);
         // ReSharper disable once CompareOfFloatsByEqualityOperator This works, but could probably be written better
         if (newvalue != Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].Brightness)
         {
             var tempControlIntValueObject = new ControlIntValueObject();
             tempControlIntValueObject.Characteristics[0]     = new ControlIntValuePayload();
             tempControlIntValueObject.Characteristics[0].AID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceAID;
             tempControlIntValueObject.Characteristics[0].IID =
                 Lightbulbs[Lightbulbs.FindIndex(i => i.Name == name)].RemoteDeviceBrightnessIID;
             tempControlIntValueObject.Characteristics[0].Value = (ushort)newvalue;
             var stringToSend = JsonConvert.SerializeObject(tempControlIntValueObject);
             HBCrestron.hbHttpClient_SendRequest("characteristics", "", stringToSend);
         }
     }
 }