Yes as @Catman said, create a virtual switch for each user (let’s call this ‘Home Switch’) and use reactor to turn the switch on when said user is home and off when they’re not.
You will need a few things to make this work: Reactor, Alexa TTS Plugin, Switchboard plugin
To begin create a virtual switch, this one will trigger the TTS command. Connect this switch to Alexa (let’s call this switch the ‘TTS trigger’) and create a routine with it and name it “who is home” and have it turn the virtual switch on.
Back in reactor create an ‘AND’ group and name it ‘Who’s home’ add a condition if ‘TTS trigger’ is on in one subgroup, and in another ‘OR’ Subgroup create the conditions if either of the ‘home switch’ are on. This way when the Alexa routine runs and someone is home (one of the ‘home switch’ is on) the condition will go true.
Now you’re going to want to set a few expressions. This part I’m not 100% sure on but I’ve given a try so it should work. In the reactor sensor head over to the expression tab and click create new expression. Name this variable VSwtich
and copy paste this into the next box over list(687,692,453)
replace those numbers with the device IDs of those Virtual switches you made to signify what user is home.
Then create a another variable and name this one VSwtich_On
and copy paste this into the box next to it status_lights = iterate( lights, if( getstate( _, "urn:schemas-upnp-org:device:BinaryLight:1", "Status") == "1", _, null ) )
. This will get the devices that are turned on (meaning that person is home).
Once again create another new variable and name this VSwtich_name
and copy paste this iterate( lights, getattribute( _, "name" ) )
This will get the name of the Virtual switchs that are on so make sure each virtual switch is named using the name of each person.
Lastly create a another variable name this message
and copy paste this " join( VSwitch_name, ", " ) + " are home"
This will create the text string that Alexa will read out. Note that if one person is home it will still read as ‘… are home’ which isn’t grammatically correct ;).
In your activity section for the conditions above create an activity when the ‘Who’s Home’ group goes true set a device action for the Alexa TTS plugin and set the ‘text’ variable to {message}
. Then add an another device action to turn the ‘TTS Trigger’ virtual switch off. I can help you set up a command so that if no one is home Alexa will say that too but give these steps a try first and see if it works.