EG 0.5.0-rc4
Windows 10
Basically I am using Autovoice (see android/tasker) to send my pc commands through Join (new Autoremote if anyone knows either). Join is just a bridge that sends variables to the pc which triggers handy little events in Eventghost.
My end goal is to have a structured command process to accomplish specific goals.
So if I want to open a specific station on pandora for instance I'll send a command such as "play rock radio"
Just in case this is relevant I will give the simple regex filter I am toying with:
Code: Select all
(?<command>play) (?<genre>.+) radio
Code: Select all
Autoremote.Message.play,genre
the problem here is that comma (Autoremote.Message.play*--->>,<<---*genre)
EG reads it as one payload so If I want to parse it var[0] = p, var[1] = l, var[3] = a, var[4] = y etc. all the way to the end of the genre that is passed, which is not very convenient.
My solution below:
Macro 1
1) an event listener for something like "Autoremote.Message.play,genre" mentioned above
2) Python Script
Code: Select all
aa = eg.event.payload.arpar
# arpar refers to the payload passed by Join/Autoremote
bb = ''.join(aa)
#make the array a string
cc = bb.split(',')
#split on the comma
eg.TriggerEvent(cc[0])
#triggers text before comma as an event, this theoretically helps with chaining or filtering in various macros I might create. Throws the event "Main.Play" in this instance
eg.globals.genre_a = cc[1]
#stores the genre in a variable to be used in a moment
1) Event listener for "Main.Play" mentioned above
2) again python script/statement
Code: Select all
eg.TriggerEvent(eg.globals.genre_a)
#triggers the above stored var as "Main.Genre"
the separation into separate macros makes sense to me for this use case, because I want the "content" to be evaluated after the "quantifier". For example if I give it the "play" command with another filter of "radio" it might open a specific spotify/pandora page.
I'm sure I could of course set up a dictionary here, but I think natural language usage would be nice, I usually say "play x movie", but also say "play y song." Or open for various things (files, movies, songs).
This works at the moment, but I was just wondering if I took needless steps, or there was a "cleaner" way to accomplish this. Also sharing is fun, so if you use tasker/autovoice/autoremote knock your self out with my terrible code