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.

How to use payloads?

If you have a question or need help, this is the place to be.
Post Reply
Mplatypus
Posts: 3
Joined: Wed Mar 06, 2013 2:57 pm

How to use payloads?

Post by Mplatypus »

Hi.

I only recently started using EventGhost, and I'm loving it so far, but I'm not too familiar with it yet, and so I have a question about payloads and how to utilize them:

When I turn on my TV, which is connected to my PC via HDMI, I would like EventGhost to start up XBMC for me.

When the TV is turned on EG registers an event with a payload (System.DeviceAttached [u'\\\\?\\DISPLAY#KTC1995#5&26eb435d&0&UID259#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']).

I tried to drag & drop this event to the XBMC-startup-macro, but it didn't add the payload, only the event name.
This does work, however it also makes XBMC start up whenever I connect something else to my PC, like my android phone or a memory stick.

I tried adding the payload in the trigger event manually, but then nothing happens...

Anyone able to help?

Thanks!
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: How to use payloads?

Post by piert »

I think you need to create a python script under the action with an if-then statement, something like
if: eg.event.payload == X:
start your program command
else:
eg.Exit() #which means exit this macro right now...
Mplatypus
Posts: 3
Joined: Wed Mar 06, 2013 2:57 pm

Re: How to use payloads?

Post by Mplatypus »

Thanks man. :)

It didn't quite do the trick, I think maybe it was because the payload was so messed up. But you set me on the right path, with my very limited programming skills and zero experience with python it was very helpful.
Found eventually out that I had to use the in operator to search the payload for some unique content.

find_this = "KTC1995"
if find_this in str(eg.event.payload):
print "success!"
else:
print "not found"
blaher
Experienced User
Posts: 487
Joined: Thu Nov 17, 2011 1:27 am

Re: How to use payloads?

Post by blaher »

viewtopic.php?f=5&t=2839&start=15#p23032 has an .xml with a couple of ways of doing what you want too.
miljbee
Experienced User
Posts: 146
Joined: Fri Mar 27, 2009 1:29 pm
Location: Orl├®ans, France

Re: How to use payloads?

Post by miljbee »

the payload of this event is an array containing a string [u'something']

to get the string you have to to something like :

Code: Select all

dev = eg.event.payload[0]
then you can match it like that :

Code: Select all

if dev=="\\\\?\\DISPLAY#KTC1995#5&26eb435d&0&UID259#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}":
    print "Got it !"
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
Mplatypus
Posts: 3
Joined: Wed Mar 06, 2013 2:57 pm

Re: How to use payloads?

Post by Mplatypus »

Thank you so much guys, I got it working now, much appreciated. :D
Post Reply