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.

access second argument of url string

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

access second argument of url string

Post by Fiasco »

http://192.168.2.103/index.html?volumeZ1&1b

volumez1 is the event and the above appears like this in eventghost

HTTP.volumeZ1 [u'1b']

How do I access the 1b argument to pass it to a plugin command.
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman »

This is the payload of the event. use eg.event.payload in a macro. Since the payload is a list in this case you have to use eg.event.payload[0]
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco »

do I have to put it in curly brackets or anything? The variable I always end up getting is the string literal eg.event.payload[0]
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman »

That's right. Curly braces trigger the evaluating mechanism of EG.
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco »

also, within a plugin script how can I test to see if eg.event exists without throwing a NoneType error when it doesnt?
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman »

Fiasco wrote:also, within a plugin script how can I test to see if eg.event exists without throwing a NoneType error when it doesnt?

Code: Select all

if eg.event:
    #do your stuff
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco »

Bartman wrote:That's right. Curly braces trigger the evaluating mechanism of EG.
I've got my onkyo macros on the right screen of eventghost.

I tried putting {eg.event.payload[0]} as the argument to the macro but within the script I end up with a string literal of {eg.event.payload[0]}
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman »

call eg.ParseString to evalute the input
Post Reply