public async Task <Response <bool> > ChangeStateAsync(LedState state, int deviceType, string serialNumber) { string uri = API.Devices.ExecuteCommand(_baseResourceApiAddress, ApiVersion.v1, serialNumber, _user.id); DeviceInfracstructureActionModel actionModel = new DeviceInfracstructureActionModel(DeviceCommands.SwitchLed, deviceType); actionModel.AddParameter("state", (int)state); var result = await CommandFactory.Instance.GetCommand("BASE_POST_COMMAND") .RunAsync <ResponseInfrastructureModel <bool> >(uri, actionModel); if (result != null) { var response = new Response <bool>(); response.Value = result.HasValue ? result.Value.Value : false; response.Error = result.HasValue ? result.Value.Error : result.Error; response.ErrorCode = result.HasValue ? result.Value.ErrorCode : null; response.HttpResponseCode = (int)result.ResponseCode; return(response); } return(new Response <bool> { Error = "Unidentified error", ErrorCode = -999, Value = false, HttpResponseCode = 500 }); }
public async Task ChangeIntensityAsync(int value, int deviceType, string serialNumber) { string uri = API.Devices.ExecuteCommand(_baseResourceApiAddress, ApiVersion.v1, serialNumber, _user.id); DeviceInfracstructureActionModel actionModel = new DeviceInfracstructureActionModel(DeviceCommands.SetLedIntensity, deviceType); actionModel.AddParameter("intensity", value); await CommandFactory.Instance.GetCommand("BASE_POST_COMMAND").RunAsync(uri, actionModel); }