Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using group 0 with setLightState() #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions hue-api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ HueApi.prototype.updateGroup = function (groupId, name, lightIds) {
throw new errors.ApiError("Group Id '" + groupId + "' is not valid for the bridge");
}

// Protect the default implicit all lights group from being updated
if (groupId === 0 || groupId === "0") {
throw new errors.ApiError("Cannot update the 'All Lights' default group");
}

var parseResults = function (result) {
if (!_wasSuccessful(result)) {
throw new errors.ApiError(_parseErrors(result).join(", "));
Expand Down Expand Up @@ -315,7 +320,7 @@ HueApi.prototype.createGroup = function (name, lightIds) {
*/
HueApi.prototype.deleteGroup = function (id) {
// Protect the default implicit all lights group from being deleted (not sure if this is even possible, but do not want to risk it)
if (id === 0) {
if (id === 0 || id === "0") {
throw new errors.ApiError("Cannot delete the 'All Lights' default group");
}

Expand Down Expand Up @@ -750,7 +755,7 @@ function _isLightIdValid(id) {
}

function _isGroupIdValid(id) {
if (parseInt(id, 10) > 0) {
if (parseInt(id, 10) >= 0) {
//TODO: check group is valid
//Keep in mind, group 0 is always valid, stands for ALL lights known by hue bridge
return true;
Expand Down