public static DeviceResponse createResponse(String name, String id) { logger.Info("Creating a device response object with name[{0}], id [{1}].", name, id); DeviceState deviceState = new DeviceState(); DeviceResponse response = new DeviceResponse(); response.state = deviceState; deviceState.on = false; deviceState.reachable = true; deviceState.effect = "none"; deviceState.alert = "none"; deviceState.bri = 254; deviceState.hue = 15823; deviceState.sat = 88; deviceState.ct = 313; List <Double> xv = new List <Double>(); xv.Add(0.4255); xv.Add(0.3998); deviceState.xy = xv; deviceState.colormode = "ct"; response.name = name; response.uniqueid = id; response.manufacturername = "Philips"; response.type = "Extended color light"; response.modelid = "LCT001"; response.swversion = "65003148"; return(response); }
// GET api/{userId}/lights/5 public HttpResponseMessage Get(string id) { logger.Info("LightsController called (// GET api/{userId}/lights/{id}) Retrieving light with id[" + id + "]..."); Device device = Globals.DeviceList.FindById(id); if (device == null) { logger.Warn("LightsController GET: Could not locate a light with id [" + id + "]."); return(new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.NotFound, ReasonPhrase = "Could locate a device with that id." }); } logger.Info("LightsController GET: Returned DeviceResponse for device named[{0}], with id [{1}]", device.name, device.id); DeviceResponse response = DeviceResponse.createResponse(device.name, device.id); return(Request.CreateResponse(System.Net.HttpStatusCode.OK, response)); }