Hmm, you are right, then I guess that is a feature request, and until then, just add all your members with “someone specific is asleep” in the AND column, just a little bit cumbersome if you have a lot of members though.
I had the same requirement and I only wanted to consider people who are currently at home. So I wrote the following script. Just copy paste it onto HomeyScript and you can use it. You cannot trigger a flow on this script, but if you trigger on “someone goes to sleep” and then run this, you get the same result.
// returns true if everyone who is at home, is asleep
let allUsers = await Homey.users.getUsers();
let result = true;
_.forEach(allUsers, user => {
if(user.present == true && user.asleep == false){
//there is someone at home who is awake
result = false;
}
});
return result;
Tested it. It doesn’t. But it quite simple to check if everybody is asleep with the card ‘a specific person is asleep’ and ad al family members in the and section
I know I react on an old topic but I think it’s better than start a new one.
The script above has helpt me so much. I was looking for it a long time.
I’m also looking for a script that returns true if the first person thats wake up and is home.
But if the second person wake up and there’s already someone awake and present it has to give a false. Can someone make that?
I thought of editing that script, and add a counter for the number of not sleeping persons
Code:
// 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;
When the result = false, but you also want to know who, and if he/she/it/them was the 2nd, 3rd, 4th person to wake up:
Code:
// 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);