Wake up row: True for 1st person, False for 2nd, 3rd, Xth person. Also show who’s the 2nd, 3rd etc. persons to wake up
For fine-tuning the household’s morning routines (or: who got up last, takes out the bin )
(The top flow just returns true/false. The bottom flow is more fun)
Apps used:
Other things people need to do to get it working correct?
Here’s the code from the Homeyscript card of the top flow:
// When 1st person @home wakes up = true; when person2 @home wakes up: false.
let allUsers = await Homey.users.getUsers();
let result = true;
let count = 0;
_.forEach(allUsers, user => {
if(user.present == true && user.asleep == false) {
// for each user who is not asleep, add 1 to the counter value
count++;
// if counter is higher than 1 (person), result = false
if( count > 1 ) {
result = false
};
}
});
return result;
Here’s the code from the Homeyscript card of the bottom flow:
// When 1st person @home wakes up = true; when person2 @home wakes up: false.
let allUsers = await Homey.users.getUsers();
let result = true;
let count = 0;
_.forEach(allUsers, user => {
if(user.present == true && user.asleep == false) {
// for each user who is not asleep, add 1 to the counter value
count++;
// if counter is higher than 1 (person), result = false
if( count > 1 ) {
//Show if it was the 2nd, the 3rd, 4th (and so forth) person to get up
result = "No. Person #" + count + " got up"
}
}
});
return String(result);
Thanks for the inspiration and original script from this topic
TEF:
[tef:FLOWS:"H4sIAAAAAAACA+1YbW/bNhD+K4RWFAliuuKrKAXt3oHtSzEsG/qhCQyKPMZGHcmT5LlF4P++o2QncZqsClpgKDAgjiXqeK/PPUf5OumS4jpx9dXUdnP8jx/40LpmseofVEmR/BKXzoal7XaS2KR4e50s8EkZBKSQBgpZmlGpc09N5nLqeMi5gQxcmiWTXsmvgbC2I3VDeOXJCpq2rsjGvoOWrFco46I1mefcCu+pknmK+rSlhueB5lCWXlrOoFRR7n1SyDSdJB+SQhn8rtFA73hhV6vi4WAmvcfNuvqx9vA7dOumas+6ZlFd4iOMNbGuW9QV3rQYX+JBoCdG0RRKjq54TfOgDC0zlvEsCKO9TS76ZMT0eUANL16QN3Oo+kB3EX4XXbiJk7wkXbOGU7KJYoMIvydTkGCXLUzPqyV0xC6Xf7Yohzvtxi460hdjuo5r00vo+odHx6eDdAPtetnt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