public bool Equals(LifxSetting lifxSetting) { if (lifxSetting == null) { return(false); } return(lifxSetting.Brightness == Brightness && lifxSetting.Color == Color && lifxSetting.Duration == Duration); }
public async Task ChangeBulbSettings(string bulbLabel, string color, double brightness, double duration = 0.1) { LifxSetting lifxSetting = new LifxSetting() { Color = color, Brightness = Math.Round(brightness, 1), Duration = duration }; if (!lastSettings.ContainsKey(bulbLabel)) { lastSettings.Add(bulbLabel, lifxSetting); } else { if (lastSettings[bulbLabel] == lifxSetting && lastSettings[bulbLabel].AgeSeconds < 12) { return; } lastSettings[bulbLabel] = lifxSetting; } LightSettingDto lightSettingDto = new LightSettingDto() { color = color, brightness = lifxSetting.Brightness, duration = duration, fast = true, infrared = 0, power = "on" }; log.Add($"{GetTimeStr()}: {bulbLabel} -> {color} in {duration}s."); ByteArrayContent byteContent = ToSerializedBytes(lightSettingDto); if (!bulbLabel.StartsWith("group:")) { bulbLabel = "label:" + bulbLabel; } HttpResponseMessage httpResponseMessage = await client.PutAsync($"https://api.lifx.com/v1/lights/{bulbLabel}/state", byteContent); if (await ErrorsReported(httpResponseMessage)) { return; } //string result = httpResponseMessage.Content.ReadAsStringAsync().GetAwaiter().GetResult(); }