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

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?

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
    In the code field (with some examples in it), remove all text and enter:
  • → 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"
    … 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}`)

        uri: 'homey:manager:mobile',
        id: 'push_text',
        args: {
			    user: {
			    athomId: myArgs.userX_athomId
		    text: myArgs.my_push_message + '\n\n(Optional: Flowname)'

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


Thanks Peter! Will try this out tomorrow

1 Like

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.

(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).

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:

1 Like