public bool SetLights(string groupName, SmartLightState state) { bool result = false; if (this.Groups != null) { SmartLightGroup groupToAffect = null; foreach (SmartLightGroup group in this.Groups) { if (group.Name == groupName) { groupToAffect = group; break; } } if (groupToAffect != null && groupToAffect.LightIds != null && groupToAffect.LightIds.Length > 0) { SmartLight[] lights = new SmartLight[groupToAffect.LightIds.Length]; for (int i = 0; i < lights.Length; i++) { lights[i] = new SmartLight(groupToAffect.LightIds[i], state); } result = SetLights(lights); } } return(result); }
public SmartLight(SmartLight light) { if (light != null) { this.Id = light.Id; this.State = new SmartLightState(light.State); } }
public SmartLight[] GetLights() { SmartLight[] result = null; lock (this.UpdatingDataLocker) { if (this.CurrentLampStates != null) { result = new SmartLight[this.CurrentLampStates.Count]; for (int i = 0; i < this.CurrentLampStates.Count; i++) { SmartLightState state = new SmartLightState(this.CurrentLampStates[i].State); state.Intensity = (ushort)Math.Round(state.Intensity * 100.0 / 255.0, MidpointRounding.ToEven); result[i] = new SmartLight(this.CurrentLampStates[i].Id, state); } } } return(result); }
public SmartLight(uint id, ushort intensity, SmartLightColor color) { this.Id = id; this.State = new SmartLightState(intensity, color); }
public SmartLight(uint id, SmartLightState state) { this.Id = id; this.State = new SmartLightState(state); }