Пример #1
0
        /// <inheritdoc/>
        public async Task <string> UpdateLightAsync(long id, HueLight.BulbState state)
        {
            if (credentials == null)
            {
                throw new UnauthorizedAccessException(UNCONFIGURED_EXCEPTION);
            }
            string url = $"{credentials.APIURL}lights/{id}/state";

            try
            {
                string      stateObj = JsonConvert.SerializeObject(state).ToLower();
                HttpContent content  = new StringContent(stateObj);

                HttpResponseMessage response = await _client.PutAsync(url, content);

                string final = await response.Content.ReadAsStringAsync();

                return(final);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
 public async Task <ActionResult <string> > UpdateAsync(long id, [FromBody] HueLight.BulbState state)
 {
     return(await _hueConnector.UpdateLightAsync(id, state));
 }