Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

A Regex Plugin for Events

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

A Regex Plugin for Events

Post by Flyingsubs »

I am not sure how to code in Python but i wanted to explore this idea. The reason i want to make a pluggin, is the ability to take a voice command send it to eventghost and the parse it. I already use the HTTP Send to eventghost and i am able to process only one command at a time.

I would like to be able to handle multiple commands: Turn off the light and turn off the computer. The pluggin would recognize the word "and" and split it up into two events and send them seperatly.

Turn off the Light
Turn off the computer.

Is this already implemented? Any one have any pointers of where to start?

Thanks,
Flyingsubs
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: A Regex Plugin for Events

Post by Sem;colon »

well, you won't need a plugin to split a command into two...

your HTTP request in EG sould look like: HTTP.command [u"Turn off the light and turn off the computer"]

You can just use a phyton script like:

Code: Select all

data=eg.event.payload[0]
data=data.split(" and ")
i=0
while i<len(data):
    eg.TriggerEvent(data[i])
    i+=1
this will generate the two events:
Turn off the light
turn off the computer

(not tested)
If you like my work, Image me a drink :wink:
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: A Regex Plugin for Events

Post by Flyingsubs »

Oooh, thats a good idea. Thank you. I guess since all incoming payloads are http., i should have it always check for the "and". What if i wanted to do 3 commands in one sentence. How would the script differetiate? I guess for every "and" its splits the payload.

Well at least i have something to play around with and try out myself. Thanks again!


-Flyingsubs
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: A Regex Plugin for Events

Post by Sem;colon »

Flyingsubs wrote:Oooh, thats a good idea. Thank you. I guess since all incoming payloads are http., i should have it always check for the "and". What if i wanted to do 3 commands in one sentence. How would the script differetiate? I guess for every "and" its splits the payload.

Well at least i have something to play around with and try out myself. Thanks again!


-Flyingsubs
you're welcome!

Two times " and " will generate 3 events and so on...
If you like my work, Image me a drink :wink:
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: A Regex Plugin for Events

Post by Flyingsubs »

I really want to get into the python side of eventghost. I have a few stability issues that I think would be fixed if i coded in python. Every so often a macro executes but doesn't do everything the macro was suppose to do. IE execute another macro. Seems like i might be extending the limitations of eventghost.

-Flyingsubs
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: A Regex Plugin for Events

Post by Sem;colon »

Flyingsubs wrote:I really want to get into the python side of eventghost. I have a few stability issues that I think would be fixed if i coded in python. Every so often a macro executes but doesn't do everything the macro was suppose to do. IE execute another macro. Seems like i might be extending the limitations of eventghost.

-Flyingsubs
Do it, python is a nice programming language and there are many tutorials in the web!
If you like my work, Image me a drink :wink:
Post Reply