Skip to content

Commit

Permalink
- Fixes #18, ended up deleting the rgb flag on the state object, maki…
Browse files Browse the repository at this point in the history
…ng it unusable for subsequent requests.
  • Loading branch information
osirisoft-pmurray committed Dec 20, 2014
1 parent e3bbd82 commit b9a465a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hue-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ HueApi.prototype.setLightState = function (id, stateValues, cb) {
promise = _setLightIdOption(options, id);

//TODO stateValues need to be injected properly so that they can be checked and validated
options.values = stateValues;
// Need to ensure we take a copy of the state values (as if we use rgb values you can end up making unwanted changes)
options.values = JSON.parse(JSON.stringify(stateValues));

if (!promise) {
// We have not errored, so check if we need to convert an rgb value
Expand Down
20 changes: 19 additions & 1 deletion test/setLightState-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,23 @@ describe("Hue API", function () {
done();
});
});
}); });
});

//TODO turn this into a proper test that can validate the colours correctly
//describe("with single state shared across multiple lights", function() {
//
// it("should set on and xy values", function(done) {
// state.on().rgb(255, 0, 0);
//
// hue.setLightState(4, state)
// .then(function(){
// return hue.setLightState(5, state);
// })
// .then(function() {
// done();
// })
// .done();
// });
//});
});
});

0 comments on commit b9a465a

Please sign in to comment.