public async Task <bool> SetLightStateAsync(int lightId, LightState lightState) { _logger.LogInformation("Turning light {lightId} on: {isOn}", lightId, lightState.on); HttpResponseMessage response = await _httpClient.PutAsync($"http://{_ipAddress}/api/{_userToken}/lights/{lightId}/state", new StringContent(JsonSerializer.Serialize(lightState), Encoding.UTF8, "application/json")); LightStateChanged?.Invoke(this, new LightStateChangedEventArgs()); return(response.IsSuccessStatusCode); }
protected virtual void OnLightStateChanged(LightController newLight) { LightStateChanged?.Invoke(this, new LightStateChangedEventArgs(newLight.Config.Name, newLight.IsOn)); }