[TUTORIAL][PRO] Send push message to a specific user, by using a variable

Hi all,
Don’t know if the title is covering it, but this idea popped up after reading a request, like:

  • Is it possible to send push messages to a user using variables
    (I’ve not found a howto anywhere, so I just wrote this one…)

This is possible with Advanced Flow and inline HomeyScript

Here we go. It looks harder or more complicated than it is. Just don’t hurry I’ll suggest :upside_down_face:

  1. Goto https://tools.developer.homey.app/tools/api-playground
    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:
    "name":string"Peter Kawa"
    … and so on

  2. Now create a text variable for each user, ending with athomID (for example)
    Something like:
    -Name: PeterKawa_athomID
    -Value: copy/paste the “athomId” string (without the " symbols)

  3. Now create a common text variable, which is going to be used to temporary hold the value of the selected User variable
    -Name: userX_athomID
    -Value: abc

  4. Example Advanced flow:


  1. The script used in the Advanced flow ‘And’ or ‘Then’ card “HomeyScript 'Run Code with Argument
// sendpushmsg.js: 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(Test push notification from flow using HomeyScript sendpushmsg.js)'


  1. How does it look like?
    The arguments used for the script in JSON format, and below that you see the first part of the script (see previous point 6.)

Please mind the needed "" symbols around every text or variable in the arguments list;
Right after "my_push_message":, you can enter your message, like the example

  1. Yeah all nice and stuff, but, does it actually work?
  • Push message:

  • Timeline:

Screenshot from 2022-09-10 01-14-49

Have fun!
Questions, improvements and other ideas are welcome!