Skip to content

Commit

Permalink
Fix GladysAssistant#249 : If user has only one house and say "I'm bac…
Browse files Browse the repository at this point in the history
…k home", Gladys should suppose it's his only house
  • Loading branch information
Pierre-Gilles committed Nov 14, 2017
1 parent 633dd25 commit 58ecc27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/core/brain/parser/parser.house.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = function(originalText){

return {
text,
houses: result
houses: result,
allHouses: houses
};
});
};
Expand Down
3 changes: 2 additions & 1 deletion api/core/brain/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ module.exports.parse = function parse(text) {
.then((result) => {

houses = result.houses;
allHouses = result.allHouses;
replacedText = result.text;

return Promise.resolve({deviceTypes, rooms, houses, times, replacedText});
return Promise.resolve({deviceTypes, rooms, houses, times, replacedText, allHouses});
});
};
5 changes: 5 additions & 0 deletions api/core/event/event.command.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ module.exports = function command(scope) {
if(scope.rooms && scope.rooms.length == 1){
event.room = scope.rooms[0].id;
}

// if there is only one house and you say "I'm back at home" "I left home", Gladys suppose it's your only house
if((scope.label === 'back-at-home' || scope.label === 'left-home') && !event.house && scope.allHouses.length === 1) {
event.house = scope.allHouses[0];
}

return gladys.event.create(event)
.then(() => {
Expand Down

0 comments on commit 58ecc27

Please sign in to comment.