[APP][Pro] Advanced Triggers - Trigger and action cards with eventname for Advanced Flows

I will add the advanced triggers where I need serialization, but then most likely send the arguments as a JSON in “Text1” and use your parser.

Use an Advanced Virtual Device, create fields as you like and select create tag for each field.
This avd would be your set.

Avd is from device capability.

Can you use this device as an event and send it with advanced triggers, or is it more like an advanced variable?

Well it can be made either way.
Please explain in more detail what you would like (to achive)?

I have some temperature sensors I want to check whether the temp is ok/high/low.
Before I found out that advaced flows could parse JSON I clone the temperature check flow for each sensor.
With JSON I could make one generic check flow and send the new temperatur value, high and low threshold and sensor name. But as Homeys built in JSON parser cretes tags named “Result” I got an unreadable flow with “if(Result < Result)”. It worked but looked terrible.
Then I found your JSON parser and at least now I have “if(Number1 < Number2)” and it is easy to take a quick look in the parser card to understand what they mean.

Homey-temperature-check

With your Advanced triggers I would still have “if(number1 < number2)” but I would need to remember what “Number1” was as there is no explaining label for it. And when starting the event I would need to check the called flow to set correct arguments. So, a bit back to Homeys JSON parsing.
This is where it would be nice to have tags with own labels, and I could have “if(temperature < thresholdLow)”.

I could achive this with Homeyscript but I like to have the flow grafically if possible.

Hey Gregow,

Well, yeah, dynamic tagnames are possible, linked to a device or app.
For instance, you could create an AVD with fields with the disired tagnames.
Issues is, thaat it will not be scoped: executed the flow where you use that AVDs tags twice at the same time, and you will get straigns results.
Afaik, there is way that i could create scoped tags/variables that have a tagname that can be set dynamicly.

What i mean is:

  • If i create dynamic tagnames through App or a device, those are scoped to the device/app, not the flow. So you cannot run the flow twice at once or the results are “random”.
  • If i create flow-scoped-tags or variables, i can only do that through flowcards which have pre-install-defined-tagnames.
    I could for instance create a actioncard that retrieves scoped values/tags from the background (when you give an extra FlowExecutionID, just like Retunr cards), but then you are back at tags like Text1, Text2, etc.

How? Or do you mean, i could write it in code and in the code it would be more readable because of beter in-code-variables? There is no way you can use HS to create beter (scoped) tags, right?

Sounds like there is no perfect solution for this.
I could use AVD and create my tagnames and then use “Advanced triggers” to serialize the calls to the flow. That would protect the AVD.

I mean that if I use HomeyScript instead I would do all calculation in code.
I do not know node.js (yet, will learn soon) but something like:
int temperature = json.parse(“temp”, arg[0]);
int thresholdLow = json.parse(“threshold”, arg[0]);
if(temperature < thresholdLow)
{
}
More readable. But not graphical coding. :slight_smile:

Indeed, a solution could be created to easily parse an AVD(s values) as JSON to use in HS.
But i don’t see a (card/tag) solution for Advanced Flows.

No, seems not to be easy.

I, and many more, have allready, in various ways, asked Athom for “scoped variables” or something simular.
And perhaps it might come some day.
And than at least you could create scoped-variables and set them at the start of a flow with the arguments, so the rest of the flow becomes very readable.

But as long as i/developers have no control over the values retrieved directly by tags (so we could scope them), the solution lays with Athom alone.

1 Like

I started to use the Adv.trigger now.
What is “Flow execution ID” in some of the cards?

Advanced Triggers
“Return Triggername(Flow Execution ID) with (Text 1, Number 1, Yes/No 1)”

I see that some of the cards has “Tag” instead??

Advanced Triggers
Start Triggername/Tag with (Text 1, Number 1, Yes/No 1) and Set Wait to…

Hey Anders,

Those are two different things:

  • The alternative TAG after a triggername, is just a way of entering a name through text or a token, instead of a pre-picked autocomplete-list.
    This makes it easier to start flows dynamicly; You dont need to duplicate different start-a-flow-cards, just dynamicly create the names.

Now, about the Return Cards and there needed Flow Execution ID.
You can have a big advanced flow started with an advanced trigger and then have that flow return something to the startflow card.

Here is an example.

When you execute the top-left card it will run the bottom row (not in de editor ofc.) and that row will return the values as tokens to the first(!) top-left flowcard. Now you have the response from the scoped bottom line!
This example for instance, will write "This is the response if false! into the SimpleLog.
If you switch the Logic Card around to 1 equals 1 (and save the flow) and execute the top-left card again, it will now have a different response in its tokens.
The flow executionID is needed to make sure the return value belongs to the right flow execution.

TEF can be imported through App Settings in Device Capabilities App

[TEF:FLOWS:H4sIAAAAAAACA9WUS2vcMBDHv4qr8ypYtmzLuvVUCoVCk9uyLHqMsyJe27HlPAj73TuWnYQ8IE6gh4JBjDQezfz+o3kgnsgH0tRn1/U4eOip82ff7Y1qDNiL3l1eQj8EDyLJ4370dHDaTL82DurBwlUN/dVZ3V4++p+7Y1dD9Ov3D3JCT0Xk9oE4PKjiFEQhYioExJRblVKRG0GTRJsytpDHpiSbEGP/B/zYN5GHweMWEOn7ETbETJcwUQrFdUqTsrKUx4WiolKMGuBMW5EnZRn87oiMN+SeSJbj2mLYQ3uEe6m6Tn5Q+iYk7Gdzv/dw59m+GY8aerbXbVuDahh6+WcvtBDZlnCuNS/zmGpIsMpYAdU2A2pZphTEuU2SkuwCF+SljvC8kpdVWxhM7zrv2iCDao7qChqEilRzoU3FWUULZgvKiyyjSheamlykwJU2ePvCQIiZgvgahD7k9AEDZUKWn6/qHGowHhAfFhWuwM2Lgxsi/PwBoh6Grm0GiFwVTT3wDUNUdXsLd2DGKYiz+Md2u6gg5ZrukPJViN0u9KpJhCiRH01FjlRFDLRMLVCu80olVlVZpReqyUKVf43qDGwt1dBYDHTJUg000Yyh5CWnpU4T1D1POWMZlpZ9pbHelQC9bpXzvq1c44bD/P4mRKuymBFxPiN6j9Cb4TFj+dl0o9/P9tu+CkMGtZ53pVwjl5ShpEXgVY/zZfavhsdRNWrqM8zFmSVruB7VkueUtGkb6xa79ZN0q14rStdWkzdYa5guGGVacMpLy7AsxanlVZ4pozPI7JPQN6oeYVJsapq2g175tg85oR0Ok3CIxfeLipt1N7ycHkn+34+PStXDv5wfp9Pu9BcsS2+qWgcAAA==]

These Return cards make it possible to create Flows like Programming Methods, it’s a partial replacement for HOOP.

1 Like

Ok, I think I understand. Or no…
The Return-card is used for exiting the flow with arguments, so should be last card in the flow (but doesn’t have to) as it will let the caller flow continue if it is waiting?
And if you returns a Execution ID you may use it when the flow is started to know which flow is starting it?
Where is the Execution ID created? Automatically when flow is started?
But how do you use the Execution ID in the flow? I see that you returns it but I do not see your flow using it for anything. :slight_smile:

What would happen if I do not enter any Execution ID?

Indeed, the Callercard will wait for all triggered flows to be completly finished with the whole flow (so don’t put waits with more then 30 seconds in it, it will timeout), and then it will get the tokens from the first executed Returncard (there could be (by mistake) multiple returncards executed because you can trigger multiple flows or have multiple return cards)

Well, yeah, i guess so, the ExecutionID is generated at the Start-A-Flow(Then)-card and all triggered (When)flowcards will have the same ExecutionID, see the example below.

I think you have the thought here, the other way around: The Returncard has no idea which flow it is in, when a flowcard is executed (like the return card) the App only knows it’s given arguments, i do not know which trigger it belongs to or which execution.
The lines you see in the editor; the app has no idea about those lines and there is completly no way, hacky or not, to know those lines (since you can have duplicated cards with the exact same arguments, and those are the only ones to start the search from with certainty).
So, it is the Returncard that needs to know which trigger it belongs to.
Now, i could make the ExecutionID completly unique, but since the return card is ment to give a returning value to the actioncard (Callercard) i use the same executionID for all triggered flows with the same name. This is on purpose but could be change or when needed a Unique Execution ID might be added.
Perhaps i should call the current one ReturnID instead of ExecutionID?

:slight_smile:
The exact same thing that always happens when you use a Start-a-flow-card: It will execute the flow and, if selected, wait to finish, and then its finished: the tags will be empty.
The return card will be waisted.



These logs will write the same-as-each-other executionID everytime you execute it.

image

[TEF:FLOWS:H4sIAAAAAAACA72TQYvbMBCF/0rQOQqyJNuSbwstZaHQQ3sLwYykUdbEsVNb6SYE//fKTtIldOmGZenFRtLzG803zycSSHEiTb34We/7gB2twuLB/YLGovvRVes1dv2kIAW57s/+HAzz8dOmwrp3uKmx2yzqdn3Vf6+2uxpnX799IUNUAimWJ1LFA6cTzzFzlCXOUSm8pCZXCZWeaVCp9hnLyHzyKD8f0O5D1Tazx08zPMBoGc+QFKHb45zYsZrHXHApEgpKWyrTaK2cE9TYaIUWQNl81B1IwebkSArO47uN/k/tFo8F7HbFGwzm083DeVmWAQ8hKZv91mCXlKZta4QmiarwooqryG5JtNeSi0xRa3RsMoeUKouMpsoppVFI4xlZTYAiONjiy5vctB+wD9HUYW+7ajfujpSxRhswlhtGysiTyNIC5VxlVGY8oyblOeVOZyABnEK8oEjkBcb7WIAdb/AGirPoQuLdPT5As4UNNmPgpnJxL4qeoQqh9VVT9U/XPIye5hhgPUpGIHfRPwOR7F/p+CvmZwyPzW4fyvP6puOp1el3IMvlJRJFcU9Uo6pun/GKpXKr1dSK8tJpnxrKPBNUJkxS0Gl8eLAyF0aANDcxF9l/jLlI8pxnHKkyLKXSOKRaOEaRp4IhiFwJ+LCY31Xsdqqvw/iYqd4zmdenOgyr4Td5hN6BhgUAAA==]

Come to think of it: The Eventname within the Returncard is absolutly useless, i don’t know why i included that :slight_smile:
Might be because i started off differently.

I’m improving the cards right now to make stuff more clear.

1 Like

I think I understand now.
The Execution ID (think the naming is ok) is used to connect the returning-arguments to the correct caller. So if a flow is triggered by more than one Adv.trigger you need to select the correct Execution ID (from the correct trigger card) that you want to send the return-arguments to?!
I think the Execution-ID-field in the return card should be mandatory then (maybe it allready is).

Ok, so only the first return-arguments are received by the then-start-card, even if more than one flow is triggered and having return-card. Good to know.

Maybe “Trigger card ID” is a better name? As it is for connecting to correct trigger-card, if I have understood everything.

I am changing it tho, because i am changing the cards (just in names, everything will keep working) and it is better this way i think. Also, there might come a real ExecutionID some day, so beter to be clear on it now.

Here is what the version that is in test now, looks like:

image

Output:
image

[TEF:FLOWS:H4sIAAAAAAACA71VXWvbMBT9K5meoyJLsj78VtgYhcFg61sI4Uq6Tk0dJ3OUNaXkv0+2m2bZV00Je4mQdHJ17zn3XD+RSIon0tRX3+rdNmJLq3h1Hb5D4zHcttVyie22R5CCHM8nLxeHaffXpsJ6G/C+xvb+ql4vj/iv1WpT4+TT54/kkJBAitkTqdJFsFnJUQXKshCoFKWkTpuMypJZMLktFVNk2sdYfMG4a5vJzfsJ7qGLly6QFLHd4ZT47qkSteBSZBSM9VTmKa4JQVDnUxz0AMbrDrcnBZuSR1JwntZ1Cn63XuFjAZtN8QoB0z7tOGwXi4j7mC2a3cphmy3cel0jNFlCxRMq7RJxM2JLK7lQhnpnU4Uacmo8MpqbYIxFIV3JErYUijmnNbUh2FSEFxRAO8o9U96B95YDmfckJnJhhaeVnCj68EJRwK1vq02s1r0SWKOPmLI6dEogzxLfHijnRlGpuKIu55ryYBVIgGAQnxkzA2VvIwx89/4rfA2gI12gDbelVzSlYKj0ylGndEm5tVZ5XWppwtt5uIZmBffYdI3bJ5XOEugBqhjXZdVU27tja3Ux3WOEZQfpSBsl5ECaZP9qtN/sMpB102x2cTHsz3jpS+1tRWaz5+4qijFdn1D1+gH36HddrCrM530pppTBlrmjrGSCyoxJCjZPPyV4qYUTIN2ZY1Jz/j/HiExrrjhS41hOpQtIrQiMIs8FQxDaiMtZYdRj56r+mYzLqDpGmb+pOmqEnJeSvXEStj3NY43dv/pLzpdp5pOLb9M6GdJ6N3xtxgySczYuLutwWhRj5m1R9KUcHQpMaqUtVQJY91001CIqCrnKkIHSAo4O5T9J2aWyjdDGo5dGTfp5csL88AMzB5FpCwgAAA==]
1 Like

Hey Arie,

When I use your example with delay blocks for the 2th and the next ones it works, but when from 2+ flows got triggered at the same time it is not doing anything. Setting trigger mode to standaard, all 3 texts are coming out but not sequential offcourse.

Works:

Doesn’t work:

Feature request would be to know when the last queue trigger is finished to trigger music again on my chromecast.

Hey,

I’ll fix it and add a card the know when a queue gets cleared.

I do have some business to attend to first this week and when i have time for the Apps, i’ll first by busy updating BetterLogic to SDk3.

After that, i’ll pick up the support/feature-request list again.

1 Like