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

**URL:** <https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400>\
**Category:** Questions & Help\
**Created:** [February 12, 2023, 8:10pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400 "2023-02-12T20:10:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [February 12, 2023, 8:10pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400/1 "2023-02-12T20:10:51Z")

</div>

Maybe a stupid question (or already been asked a lot of times) but I can’t find it.  
I would like to send a push notification to the user that pushes a virtual button. Is it possible to get that info (active user) inside a flow or homey script?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [February 12, 2023, 11:02pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400/2 "2023-02-12T23:02:43Z")

</div>

It is possible when you use an [advanced virtual device](https://community.homey.app/t/app-pro-advanced-virtual-device-device-capabilities-app-with-unique-text-status-indicator/68198) button, available per [Device Capabilities](https://homey.app/a/nl.qluster-it.DeviceCapabilities/) app.

- Button type and settings  

- Flow  

### How-to create and fill the user ID variables

1. Goto [https://tools.developer.homey.app/tools/api-playground](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:

```auto
// 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_”):

> [@The Flow Exchange(r) - Exchange Your Flows with Others!](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/25):
>
> When someone leaves, send a push message to that person Homey hasn’t got a possibility where one can send push messages or push confirmation\*\*\* questions to a user, by using tags/variables. So, no need to create a separate flow/routine for every user anylonger \*\*\*) push msgs and confirmations should be responded to within 30 secs. (HomeyScript limit). Apps used: [HomeyScript](https://homey.app/nl-nl/app/com.athom.homeyscript)How-to fill the user ID variables Goto [https://tools.developer.homey.app/tools/api-playground](https://tools.developer.homey.app/tools/api-playground) I…

---

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [February 12, 2023, 11:13pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400/3 "2023-02-12T23:13:39Z")

</div>

Thanks Peter! Will try this out tomorrow

---

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [February 13, 2023, 3:54pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400/4 "2023-02-13T15:54:43Z")

</div>

I managed to get it working! The advanced virtual device app is very complex to me, but it does the trick.  
Do you know if it is possible to use the icons of Athoms build in virtual devices? I used the below ones and I really like them and would want them on the advanced virtual devices as well.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/e/3e24450c01d4bc7ff0ce9317bf080677242413c3.png)

(FYI: I use the buttons to execute a homey script that calculate the 5 best upcoming periods of x hours - the time needed for these deviced to run - within the dynamic price range of today/tomorrow, and send the result to the person that pushes the button).

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [February 13, 2023, 4:46pm UTC](https://community.homey.app/t/is-it-possible-to-get-the-active-user-in-a-flow/76400/5 "2023-02-13T16:46:54Z")

</div>

Nice! Yes the AVD can be very intimidating at first, it has so many possibilities and settings.

The trick here, is sending the switch states to Insights, and that way, the user & used client which pushed the switch, can be retreived.  
By default, only numeric values end up in Insights, so the Athom VD cannot be used for getting the user which pushed the button, at least not with the solution with AVD, and I don’t know other ways to accomplish that.

In the mobile app, you can select the Athom icons you want after you created an AVD, just like with any other device tile:

> ![signal-2023-02-13-174603_002](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/e/bec6dd7e9457593bcc1020c0ace5a5ddb43e0193.jpeg)
