Skip to content

Commit

Permalink
send mode id into scope in mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Dec 10, 2016
1 parent 2213033 commit 24484be
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions api/core/mode/mode.change.js
@@ -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
}
});
});
};

0 comments on commit 24484be

Please sign in to comment.