Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send mode id into scope in mode change
- Loading branch information
1 parent
2213033
commit 24484be
Showing
1 changed file
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
var queries = require('./mode.queries.js'); | ||
|
||
module.exports = function(params){ | ||
|
||
if(!params.house || !params.mode){ | ||
return Promise.reject(new Error('Missing parameters')); | ||
} | ||
|
||
// get mode id | ||
return gladys.utils.sqlUnique(queries.getByCode, [params.mode]) | ||
.then((mode) => { | ||
|
||
return gladys.event.create({ | ||
code: 'house-mode-changed', | ||
house: params.house, | ||
value: params.mode | ||
}); | ||
return gladys.event.create({ | ||
code: 'house-mode-changed', | ||
house: params.house, | ||
value: params.mode, | ||
scope: { | ||
mode: mode.id | ||
} | ||
}); | ||
}); | ||
}; |