Is it possible to get the active user in a flow?

It is possible when you use an advanced virtual device button, available per Device Capabilities app.

How-to create and fill the user ID variables

  1. Goto https://tools.developer.homey.app/tools/api-playground
    In the code field (with some examples in it), remove all text and enter:
    Homey.users.getUsers();
  • → Now hit the blue RUN button above that field
  1. From the returned data, look for similar text, and copy and save these 2 lines for each user (User Name1 is an example name):
    "name":string"User Name1"
    "athomId":string"xxxxxxxxxxxxxxxxxxxxxxxx"
    … and so on
  2. Now create and edit the text variable for each user, ending with athomID (for example)
    Something like:
    -Name: UserName1_athomID
    -Value: copy/paste the “athomId” string (without the " symbols)

Homeyscript code:

// send_pushmsg: Pass your created variable [userX_athomId] and "my_push_message":"Hey [name] YourMessageHere" as argument to send them a push message;
// like this: 
// {"userX_athomId":"[userX_athomId]","my_push_message":"YourMessageHere"}

let myArgs = JSON.parse(args[0]);
console.log(`A check of the entered arguments: userX_athomId=${myArgs.userX_athomId}, my_push_message=${myArgs.my_push_message}`)

Homey.flow.runFlowCardAction({
        uri: 'homey:manager:mobile',
        id: 'push_text',
        args: {
			    user: {
			    athomId: myArgs.userX_athomId
		    	},
		    text: myArgs.my_push_message + '\n\n(Optional: Flowname)'
        },
      });
return(true);



Partly used for this idea, my original, import-able flow (“who left the house”):

2 Likes