Variable as text filter for notification on screen trigger

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Variable as text filter for notification on screen trigger

Post by javanesse » 24 Apr 2018 06:40

hy, it would be great if we can get multiple text filter or variable on "notification on screen" trigger.

the posiblity is when we get different notification on screen. we dont need to check triggers one by one. so it would be save memory, battery, time, log space and another resources.

ie. i have some trigger to show a containing of globvar into notification on screen.
my triggers are:
- trigger 1
- trigger 2
- trigger 3

and my globvar contain a list:
- apple
- brown
- clown

while "apple" shown on my screen, i'll do execute the trigger 1, and trigger 3
while "clown" shown on my screen, i'll do execute just the trigger 1.
etc

thank you so much.
Last edited by javanesse on 28 Apr 2018 11:20, edited 1 time in total.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Multiple Text Filter for notification on screen trigger

Post by digitalstone » 24 Apr 2018 10:42

I feel that using 3 triggers is not needed.
Isn't there a way you can make use of the regex filter?
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Re: Multiple Text Filter for notification on screen trigger

Post by javanesse » 24 Apr 2018 11:52

digitalstone wrote:I feel that using 3 triggers is not needed.
Isn't there a way you can make use of the regex filter?

yes, because i use the regex filter after put the empty text filter on it.
and nope, because i have many flow where have an empty text filter. so all of the flows will executed to check it one by one.

here my case:
i have lot of glovar in list format

A. globvar_one :
-0. play music
--0.0. Play music
--0.1. Play songs
--0.2. Sing a song
--0.3. Lets the party started
-1. Pause
--1.0. Mute
--1.1. Shut up
--1.2. Quite
-2. Next music
--2.0. Play Next
--2.1. Another music
--2.2. Another song
--ETC--
B. globvar_two :
-0. Wifi on
--0.0. Turn on wifi
--0.1. Wifi please
-1. Wifi off
--1.0. Turn off wifi
--1.1. Stop the wifi
-2. Check Wifi status
--2.0. Is my wifi on or off?
--ETC--

each value will give different or same task to do, so if there is no text filter, i know it can still working by give a blank text filter and then do a filtering in the expressions/script.

it will execute all flows where have blank text filter. will need lot of memory doesnt?

but if we have text filter more than one (or variable support), the trigger will execute just only one flow where contain those value/s.

i mean
- if notification give another value, another task to do,
- if notification give another value (ie. different words, or languages), same task to do,
- if notification give same value, another task to do.

thank you.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Multiple Text Filter for notification on screen trigger

Post by Desmanto » 24 Apr 2018 15:55

Do you mean you have let's say 10 flows using 10 triggers which has empty text filter? And when there is a single toast message appear (notification on screen), all those 10 flows got triggered and executed?
If yes, that is not efficient. Because single toast will execute 10 flows, and do 10 check (not counting the script global lock delay).

You should just remove all of the Notification on Screen triggers from all of the flows. And the put that into single flow only, prefer to separate flow first (the 11th flow). So each time toast message appear, only this flow got executed, and checked according to your regex upon you glovar list.

When I see your structure, it seems you have several commands and separated based on the function. Each function can have multiple commands to execute the parent function. So "Play Music", "Play Songs", "Sing a song" will trigger "Play Music" flow. I assume you do the loop to compare the toast message against each of the element from 0.0, 0.1, 0.2 and so on until it finished. And when something found, you would use the parents 0. or 1. or 2. as the command detected.

Each toast will always correspond to single command. And some toasts can refer to the same command. I would prefer to store them into a single level glovar Map only and use multiple keys to refer to the same value. It is easier to store and maintain compared to a nested 2 level list (and you even separate them again to different glovar). So you don't need the glovar one and two anymore. It is even better if you can simply redirect it to the flow name you want, so each command is the flow name to execute. Simply store them like this.

Code: Select all

global_command_database = newMapFromValues(
"play music", "play music",
"play songs", "play music",
"sing a song", "play music",
"mute", "pause",
"shut up", "pause",
"mute", "puase",
"play next", "next music",
"another music", "next music",
"another song", "next music",
"turn on wifi", "wifi on",
"wifi please", "wifi on",
"turn off wifi", "wifi off",
"stop the wifi", "wifi off",
"is my wifi on or off", "wifi status");
In the end, you have a single database center contain all the possible command in the key map, and all of the executed flow name in the value. Some different commands can correspond to the same value, thus executing the same flow. I use all lower case, since I know you are going to use it in speech recognition. All speech recognition matching should be converted to lowercase to avoid case mismatch. When the toast match "sing a song", it will proceed on to execute the flow named "play music". Of course, you have to setup the flow before and prepare the logical flow name.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Re: Multiple Text Filter for notification on screen trigger

Post by javanesse » 24 Apr 2018 16:22

exactly, thats why it would be great if text filter support multiple keywords or variables.

and yes i understand what u mean, and yes, that i just want to do, but it would be a bit complicated to add a new flow, because we must edit existed globvar map again.

actually i need the globvars and flows to be separated due simplification, so another friends/users can use my flows. what the users need is just import flow, and then go edit glovar strings as much as weird as they want to execute the flow recently imported.

and again yes, i use uppercase and make the last 2 digit of string to lowercase also trim the dash symbol instead to give a limitation of another apps to detect value if they are not a cue to be execute. :D

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Multiple Text Filter for notification on screen trigger

Post by Desmanto » 24 Apr 2018 17:18

You can maintain two glovar map. And in your main flow during the checking, add the entry before doing the check.

Code: Select all

addAllMapEntries(global_command_database, global_additional_command);
You edit current existing flow to convert it to Map structure? If that is, you only need to do it once. I have change my structure also several times, modifying the checking script sometimes from scratch, before I stick with the latest one.

The value doesn't need to be a flow name. You can actually merge all the action needed into a single flow and split them using parallel expression. You main database only execute this flow, but will supply additional variable based on the value. So the value is now the command, not the flow name. The single giant flow will have as many expression to split the command.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Re: Multiple Text Filter for notification on screen trigger

Post by javanesse » 24 Apr 2018 17:34

will try, thanks for suggestion.

report will be added soon.

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Re: Multiple Text Filter for notification on screen trigger

Post by javanesse » 27 Apr 2018 21:24

nope, doesnt meet my structure.

need variable support

User avatar
javanesse
Posts: 9
Joined: 01 Mar 2016 02:13
Location: Indonesia
Contact:

Re: Multiple Text Filter for notification on screen trigger

Post by javanesse » 28 Apr 2018 07:50

and the nightmare was begin.

adding 3 new flow commands where triggered by notification on screen.

put blank text filter as trigger, so if a notification on screen appears, each flow executed at the same time.

what i got is, executed flow
become unfinished in the middle, because got wake lock tracker remove and release in my log.

it should be unnecessary if the trigger executed straight to the point.

users can save battery life also do much many automations, based on notification on screen if it have text filter have a variable support on it.

would request alternative feature, but at this time, only notification on screen who have text filter

the last status, my project is unfinished yet. still need this one single powerfull feature.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Variable as text filter for notification on screen trigg

Post by Desmanto » 28 Apr 2018 14:12

You only need one flow to have the trigger notification on screen. All other flow don't have any trigger and only got called from this main flow.

Which part of your command need variable? It seems to be the same thing as the other has asked before in kaskus.
Using the global_command_database above, I think most likely you use a one to one mapping. So immediately assign value to the map result.

Code: Select all

recognized = "play songs";
command = global_command_database[recognized];
Using this method, your command or recognized word doesn't support variable or extra parameter. But the code is the shortest one.

If you need variable, you can use regex matching, but you must loop upon the keys now. The script will be longer, but your database can be more compact.

Code: Select all

database = newMapFromValues(
"play music|play songs|sing a song", "play music",
"mute|shut up|mute please", "pause",
"play next|another music|another song", "next music",
"turn on wifi|wifi please", "wifi on",
"turn off wifi|stop the wifi", "wifi off",
"is my wifi on or off", "wifi status");

recognized = "another music";
for(i in getMapKeys(database))
{
  find = findAll(recognized, i, true);
  if(!isEmpty(find))
  {
    command = database[i];
    break;
  }
}
Each map keys is a fully functional regex. You loop the recognized word to the map and find if any match. In the end, command will be "next music", as the it matches the regex at "play next|another music|another song". Use the is as the key and retrieve the value, break the loop (so it doesn't lookup for another key anymore).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Locked