private Task <int> CreateTmpSensorAsync() { var request = new CreateSensorRequest { Sensor = new GenericStatusSensor { Name = "temp sensor", ModelId = "TMPSENSOR", SoftwareVersion = "1.0", UniqueHardwareId = "1234567890", ManufacturerName = "TMP Sensors, Ltd.", Configuration = new GenericStatusSensorConfiguration { IsOn = true, IsReachable = true } } }; return(_client.GetResponseAsync(request).ContinueWith(p => { p.Wait(); return request.Sensor.Id; })); }
public async Task CreateSensorTest() { IHueRequest request = new CreateSensorRequest { Sensor = new GenericStatusSensor { Name = "temp sensor", ModelId = "TMPSENSOR", SoftwareVersion = "1.0", UniqueHardwareId = "1234567890", ManufacturerName = "TMP Sensors, Ltd.", Configuration = new GenericStatusSensorConfiguration { IsOn = true, IsReachable = true }, State = new GenericStatusSensorState { Status = 100 } } }; var response = await _client.GetResponseAsync(request); Assert.True(response is SuccessResponse); OnLog(response); Assert.True(((CreateSensorRequest)request).Sensor.Id > 0); }
public async Task <IActionResult> Post(CreateSensorRequest request) { if (OrganisationId == Guid.Empty) { return(Forbid()); } var sensorDto = _mapper.Map <SensorDto>(request); sensorDto.Status = DeviceStatus.Enabled; sensorDto.OrganisationId = OrganisationId; await _sensorService.CreateAsync(sensorDto); return(Ok()); }