diff --git a/hue-api/commands/sensors-api.js b/hue-api/commands/sensors-api.js index 9456a95..54cfd79 100644 --- a/hue-api/commands/sensors-api.js +++ b/hue-api/commands/sensors-api.js @@ -17,13 +17,11 @@ var Trait = require("traits").Trait , tBodyArguments = require("./traits/tBodyArguments") , tLightStateBody = require("./traits/tLightStateBody") , tPostProcessing = require("./traits/tPostProcessing") - , ApiError = require("../errors").ApiError , utils = require("../utils") ; var apiTraits = {}; - //TODO tie this into the API definition as a post processing step, then apply it via the http.invoke() function buildSensorsResult(result) { var sensors = []; @@ -40,7 +38,7 @@ apiTraits.getAllSensors = Trait.compose( tApiMethod( "/api//sensors", "GET", - "1.0", + "1.3", "Whitelist" ), tDescription("Gets a list of all sensors that have been discovered by the bridge."), @@ -48,6 +46,8 @@ apiTraits.getAllSensors = Trait.compose( ); +//TODO there are many more endpoints that need to be added to this: http://www.developers.meethue.com/documentation/sensors-api + module.exports = { "getAllSensors": Trait.create(Object.prototype, apiTraits.getAllSensors) }; \ No newline at end of file diff --git a/test/sensor-tests.js b/test/sensor-tests.js new file mode 100644 index 0000000..a2f10d1 --- /dev/null +++ b/test/sensor-tests.js @@ -0,0 +1,24 @@ +var expect = require("chai").expect + , HueApi = require("../").api + , testValues = require("./support/testValues.js") + ; + +describe("Hue API", function () { + + var hue = new HueApi(testValues.host, testValues.username); + + describe("#sensors()", function() { + + it("should obtain all the sensors in the bridge", function() { + return hue.sensors() + .then(function(results) { + expect(results.sensors).to.be.instanceOf(Array); + + expect(results.sensors[0]).to.have.property("id", "1"); + expect(results.sensors[0]).to.have.property("name", "Daylight"); + expect(results.sensors[0]).to.have.property("type", "Daylight"); + expect(results.sensors[0]).to.have.property("manufacturername", "Philips"); + }); + }); + }); +}); \ No newline at end of file