Page 1 of 1

added TriggerEvent IF to EG

Posted: Mon Mar 28, 2016 12:00 pm
by kgschlosser
for those of you that might find this handy i sure as hell did.

I added another type of Trigger Event only to the core EG plugins and not to the actual eg.TriggerEvent

it gives you the ability to enter prefix suffix and payload

it will use the usual {variablename} in any of the 3 places

it will also evaluate the payload line to see if you typed in say a list directly into the payload field

ummm has the wait time

and gives you the same 3 options as the Jump IF

"If Successful"
"If UnSucessful"
and "Always"

attached are the 2 files needed

you have to put them into your EventGhost/Plugins/EventGhost directory

overwriting the __init__.py file that's in there.

K

Re: added TriggerEvent IF to EG

Posted: Wed Mar 30, 2016 8:37 am
by Snowbird
Hi,

Thank you for this, it's a really nice addon !! :) The only "problem" is that we have to modify those files at each new release of EG, not very user friendly, it's not a big deal though :)

Thank you again !

Re: added TriggerEvent IF to EG

Posted: Thu Mar 31, 2016 12:13 am
by kgschlosser
Yeah I know but there is no other way to add it to the EG plugins other than that. so if Pako wants to add it to the next release that's kewl.


K

Re: added TriggerEvent IF to EG

Posted: Thu Mar 31, 2016 4:30 am
by blaher
I've been thinking of incorporating some sort of 'if statement' into my receiver's volume control, and I wonder if this could be the ticket?

My receiver uses infra-red, but the signal doesn't always go through. My MCE infra-red receiver always catches the signal, but if I use EG to send volume changes, 2 signals get sent sometimes.

Do you think I could use this to see if the MVL# has changed, and if it has, then don't bother sending the signal via EG?

Cheers!

Re: added TriggerEvent IF to EG

Posted: Sat Apr 02, 2016 1:47 am
by kgschlosser
yup it sure would work. it relies on the eg.result.

that is the exact reason why i made the thing was because of a similar issue.

i have one dumb button on my remote that manages to squeek in a 2nd time almost 100 % of the time. so i set a global to hold the codes as they come in and i use the time.time()*1000 to get a timestamp in milliseconds to stamp along with the code so if the same code fires to rapidly it will ignore the 2nd one.

and if it's outside the time then it flags the eg.result as true, and if it's inside set the eg.result to false.

K

Re: added TriggerEvent IF to EG

Posted: Sat Apr 02, 2016 1:49 am
by kgschlosser
the same thing could have been accomplished is i used the Jump if. but i really hate the fact there really is no visible trail of where a jump is coming from, so i would rather not jump all over the tree and have the visual in the tree of the event

K

Re: added TriggerEvent IF to EG

Posted: Sun Apr 03, 2016 5:03 am
by blaher
kgschlosser wrote:yup it sure would work. it relies on the eg.result.

that is the exact reason why i made the thing was because of a similar issue.

i have one dumb button on my remote that manages to squeek in a 2nd time almost 100 % of the time. so i set a global to hold the codes as they come in and i use the time.time()*1000 to get a timestamp in milliseconds to stamp along with the code so if the same code fires to rapidly it will ignore the 2nd one.

and if it's outside the time then it flags the eg.result as true, and if it's inside set the eg.result to false.

K
Would you mind sharing your .xml, or that portion of it, please? I understand what you mean, but programming it is another story! :)

Re: added TriggerEvent IF to EG

Posted: Mon Apr 04, 2016 8:54 am
by kgschlosser
ok i changed that up alittle bit i don't like using imports in a script unless i have to so


this is only a piece of it the rest of the code is stored in a global because it's redundant throughout my setup

Code: Select all

if eg.event.payload[1][0] == '0x3E':
    if eg.globals.RemoteDoublePress == '0x3E': eg.globals.RemoteDoublePress = False
    else: eg.globals.RemoteDoublePress = True
else: eg.globals.RemoteDoublePress = True
    
exec(eg.globals.MasterCatalog['RoomVariables'])
def PN(errNum, errTxt1, errTxt2=False):
    class text:
        err0 = "Remote Command: "
        err1 = "Remote Command not Available for this device: "
        err2 = "Button Not Found: "
        err3 = "TV Not Turned On: "
        err4 = "No Devices Turned On: "
        err5 = "Remote Code not Found: "
        err6 = "Room name not found: "
    errTxt = errTxt1+": "+errTxt2 if errTxt2 else errTxt1
    eg.PrintNotice(text.err0+eval('text.err'+str(errNum))+errTxt)

if roomData:
    remoteHex = eg.event.payload[1][0]
    button = False
    for remoteName in eg.globals.MasterCatalog['RemoteList']:
        exec("button="+remoteName+"[remoteHex] if remoteHex in "+remoteName+" else button\n")
    if button:
        evt=False
        buttonType=button.split('.')[0]
        buttonName=button.split('.')[1]
        VL = True if buttonType == 'Volume' else False
        bypassMenu = True if VL or buttonType == 'Media' or buttonType == 'Power' else False
        if (MN or buttonType == 'Menu') and not bypassMenu:
            buttonName = button if TV and buttonType != 'Menu' else buttonName if TV else None
            button = buttonName if buttonName is not None else button
            buttonType = 'Menu' if MN and not VL and buttonType != 'Power' else buttonType
        elif buttonType != 'Power':
            buttonName ='AV' if AV is not None and AV and VL else \
                        'TV' if TV and VL else \
                        'MP' if MP else \
                        'TV' if TV else \
                        'AV' if AV is not None and AV else \
                        None
            buttonType ='Remote'
        if buttonType is not None:
            if buttonName is not None:
                device = buttonName if buttonType != 'Menu' and buttonName != 'Master' else False
                buttonName = dc(roomDevData[button][['MP','TV','AV'].index(buttonName)]) \
                                if device and button in roomDevData else dc(roomDevData[button]) \
                                if buttonName == 'Master' else buttonName \
                                if not device else None
                if buttonName is not None or not device:
                    if buttonName is not False:
                        if eg.globals.RemoteDoublePress:
                            eg.globals.RemoteDoublePress = remoteHex
                            eg.TriggerEvent(
                                            prefix=buttonType+'SubSystem',
                                            suffix=roomName+'.'+device+'.'+button \
                                                        if device and buttonType != 'Power' else roomName+'.'+button \
                                                        if buttonType == 'Menu' else roomName+'.'+button.split('.')[1],
                                            payload=[eg.event.payload[0], [buttonName, dc(roomDevFunc[device])]] \
                                                        if device else [eg.event.payload[0], [buttonName, roomName]] \
                                                        if buttonType == 'Menu' else [eg.event.payload[0], [button.split('.')[1], buttonName]]
                                            )
                        else: eg.globals.RemoteDoublePress = True
                    else: PN(1, roomName, button)
                else: PN(2, roomName, button)
            else: PN(3, roomName, button)
        else: PN(4, roomName, button)
    else: PN(5, roomName, remoteHex)
else: PN(6, eg.event.payload[0])

you have to really look it's the eg.globals.doublepress variable, i dripped on in a MainOnInit action so that way it fores off right when eg starts up so i won't get any traceback errors.

but all the rest are here, it's kinda like a door that once through it locks until the next code if its the same bounces off and that bounce unlocks the door, or if a different code comes through it's allowed and opens the door and keeps it unlocked again until i get that nasty repeat bugger again.


i think

errrrr i was really not awake when i did this, but it does work.

LOL


K

Re: added TriggerEvent IF to EG

Posted: Tue Apr 05, 2016 5:08 am
by blaher
Thank you, I'll see if I can incorporate it into my setup.

Hmmm, looking at it, it's going to be a bit harder to differentiate between the two.

Here's a pic of what I mean: The first remote signal trigger is with no EG signal being sent via the network. Volume goes up once.
The second part after the EG volume macro is enabled, volume goes up twice.

But the only difference seems to be the volume change via the network is updated before the IR signal is received, but I don't know how consistent that is.

If I get a volume change before a remote trigger I could disable the EG part for 10 seconds, or so, I guess.

Something similar to the pic below, but obviously the logic is missing. :/

Re: added TriggerEvent IF to EG

Posted: Tue Apr 05, 2016 12:16 pm
by kgschlosser
ok
your problem is simple.

ad a wait in there after the first proper one hits.


make it like no more then 0.1 for a wait time

that will stall all events from triggering

then right after that wait put the flush events in there or clear events... whatever the hell it's called.


that will clear all events that are pending because of the wait.


that should cure your problem.

k

Re: added TriggerEvent IF to EG

Posted: Tue Apr 05, 2016 12:22 pm
by kgschlosser
you can really fine tune that wait time also. all remote controls have a constant time they cycle to ir,

they do that just in case the first doesn't hit.

be happy it's not an NEC code, they have a rotating code per button press

it will be one code on one press then another code when you press the same button

now the hack i did to my remotes allows me to put whatever code i want on whatever button i want.


so i actually timed the transmitting speed, and a sony12 code is the fastest at 45 milliseconds between sends.

but there is a hitch to that one.. it sends out 3 in succession each time.

i use the same kind of a method but have the wait time slowly diminish (just in case i want to hold down the volume button or scrolling through a long guide) .

and then the wait will reset if a different code comes through or more than 70 milliseconds go by between pulses.

it should be fairly easy to accomplish this in eg. i did it in c++ for an arduino.



K

Re: added TriggerEvent IF to EG

Posted: Sat Jan 19, 2019 4:53 pm
by topix
While surfing through the forum i found this thread. How about adding it into future EG version?

Re: added TriggerEvent IF to EG

Posted: Sun Jan 20, 2019 10:27 am
by kgschlosser
I believe that can be done.

I completely forgot about this feature. It is mighty handy.