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.

Question regarding wildcards in events, Is my script ok?

If you have a question or need help, this is the place to be.
Post Reply
m1abrams
Posts: 4
Joined: Tue May 20, 2008 12:20 pm

Question regarding wildcards in events, Is my script ok?

Post by m1abrams »

Ok so I am pretty happy with EventGhost and I have only been using it for a couple of days. I can see a lot of things I can do with this. So far I have setup EG with SageTV to handle channel change events from SageTV for 2 different STB tuners using a USB-UIRT. Below is the script I used, I found the basis on the forum and tweaked it a bit. One thing I did was have it pad the channel number with zeroes to 3 digits because my tuners will change immediately on the 3rd digit instead of waiting a timeout period. I could have had it send and "Enter" command but that would only at best save me 1 ir transmit and require me to make sure NOT to send the Enter when I have 3 digits in the channel. Other thing I changed was I parse out the tuner info from the event so that I know which tuner to change the channel on.

I have two sets of marcos for IR transmits for numbers 0-9, 1 set for top tuner, 2 set for the bottom tuner.
The script is triggered on the event Main.* , SageTV sends an event to EG that is of this format.
Main.STB.STBTop.212

Where 212 is the channel number, and STBTop is the tuner. The other STB I was hoping I could use as the trigger event like Main.STB.* however that does not seem to work. Is that type of wildcard not possible? Right now with Main.* the python script actually triggers itself so I put in some logic in the script to try and finish "quickly" when it triggers it and is not the target event. Seems like having it trigger on such a wide target could cause some performance issues, particularly as I move forward and have more items that it may trigger on. Should I be concerned?

Anyhow my post is two parts:
1. Anything I should do to tweak my script?
2. Is their a way to define the event so that I do not trigger on so much? Right now my event is Main.*

Code: Select all

# get the event
event = eg.EventString

parts = event.split(".")
if len(parts) == 4 and parts[-3] == 'STB':
    tuner = parts[-2]
    channel = parts[-1]
    if channel.isdigit():
        channel = channel.zfill(3)
        # iterate over every digit 
        for digit in channel:
            # send an event for the digit
            eg.TriggerEvent(tuner + '-' + digit)
Bonus Question: I was thinking I have basically 2 copies of my ir transmit macros where I am only changing the output port for the USB-UIRT between the 2. Is their any way I could just have 1 set of macros and have it based on the event sent to the macro determine which port to send. Event could look like this Main.STBTransmit.* and send it Main.STBTransmit.Z1.2 Course this would also need a way to do wildcards at different levels.
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Question regarding wildcards in events, Is my script ok?

Post by Bartman »

It should work with two parts and a wildcard as well.

Code: Select all

eg.TriggerEvent(tuner + '-' + digit, prefix="prefix")
lets you choose your own prefix. You can also add an paylod

Code: Select all

eg.TriggerEvent(tuner + '-' + digit, prefix="prefix", payload=tuner + '-' + digit)
m1abrams
Posts: 4
Joined: Tue May 20, 2008 12:20 pm

Re: Question regarding wildcards in events, Is my script ok?

Post by m1abrams »

I just tested that wildcard at the second level again and it does not trigger.
I have event Main.STB.STBTop-212 and the event trigger is Main.STB.* note Main.* does work.

However modifing my script above to send a custom prefix for the channel change does reduce the number of times the Main.* is triggered.

is it possible to send a custom prefix with the command line event call? eventhost.exe -e ""?
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Question regarding wildcards in events, Is my script ok?

Post by Bitmonster »

1.
READ THIS before posting anything!
So get the latest beta.

2. eg.EventString is deprecated. You should use eg.event.string or eg.event.suffix instead

3. You can also use payloads to the -e option.
EventGhost.exe -e STBChangeChannel 24
Will give you always the event "Main.STBChangeChannel" and the script can use eg.event.payload[0] and will get the "24".
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
m1abrams
Posts: 4
Joined: Tue May 20, 2008 12:20 pm

Re: Question regarding wildcards in events, Is my script ok?

Post by m1abrams »

Thanks for the reply, I did not know about eventstring being deprecated. I have been trying to find all the docs I can on EG however I am not having much luck. Pretty much read everything on the wiki. Is there a better location for the docs?

I was using the latest beta when I posted the above thread.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Question regarding wildcards in events, Is my script ok?

Post by Bitmonster »

Main.STB.* works here on Main.STB.STBTop-212 events.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
m1abrams
Posts: 4
Joined: Tue May 20, 2008 12:20 pm

Re: Question regarding wildcards in events, Is my script ok?

Post by m1abrams »

I changed the script to use payloads that seems like a better solution all around. Also had to modify the script to use network listener since I changed SageTV to run as a service. It seems to be working very well now.

Oh an the second level wildcard is working, I have my Denon connected via serial and have an event trigger on DenonSerial.MV.* to cause the Volume to display via ShowOSD. Loving EG, thanks for the help and great app.
CollinR
Experienced User
Posts: 265
Joined: Tue Sep 05, 2006 7:16 am
Location: Oklahoma
Contact:

Re: Question regarding wildcards in events, Is my script ok?

Post by CollinR »

Oh and welcome to the board!

As you can see there are a few talented developers here willing to help.
Post Reply