public async Task <IActionResult> GetValue(Guid uuid, bool update = false) { try { _logger?.LogDebug($"GetValue({uuid})..."); if (!_zipato.IsLocked) { return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished.")); } if (update) { var(value, status) = await _zipato.DataReadValueAsync(uuid); if (status.IsGood) { if (value != null) { return(Ok(new ValueData() { Uuid = uuid, Value = value })); } else { return(NotFound($"Value for attribute with uuid '{uuid}' not found.")); } } else { return(StatusCode(StatusCodes.Status502BadGateway, status)); } } else { var value = _zipato.GetValue(uuid); if (value != null) { return(Ok(value)); } else { return(NotFound($"Value for attribute with uuid '{uuid}' not found.")); } } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
/// <summary> /// Sets the RGB attribute value. /// </summary> /// <param name="value"></param> /// <returns>True if successful.</returns> public bool SetRGB(string value) { var ok = _zipato.SetColorAsync(RGB.Uuid, value).Result; if (ok) { _zipato.DataReadValueAsync(Red.Uuid).Wait(); _zipato.DataReadValueAsync(Green.Uuid).Wait(); _zipato.DataReadValueAsync(Blue.Uuid).Wait(); Refresh(); } return(ok); }