Cancel / stop macro if another event happens.

If you have a question or need help, this is the place to be.
Post Reply
Crowley
Posts: 27
Joined: Sat Dec 21, 2019 6:05 am

Cancel / stop macro if another event happens.

Post by Crowley » Sun Dec 22, 2019 10:10 pm

I'm really liking the software and have most things working like I want. However I'm having trouble getting the following setup to work:

When I Power off my AV receiver -> run script. I use "System.Device.Removed.SoundDevice.NVIDIA High Definition Audio" event. Now here's the problem, If I change the display mode on the receiver, it will trigger this event like it was turned off and then "System.Device.Attached.SoundDevice.NVIDIA High Definition Audio" shortly after. I do not want to run the script unless the AV receiver stays off.

I tried using "wait" and disable functions, but this wont work because the second event wont trigger when the macro is waiting.

Any ideas?

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Cancel / stop macro if another event happens.

Post by kgschlosser » Mon Dec 23, 2019 2:17 am

after the wait add the action to clear pending events. That will clear out the buffer so to speak..

you can also create a second macro and in that macro place the event. and then an action to enable the macro you have and then add a disable and point that at this macro... In the macro you have you add an event to enable the other macro and disable this one..



macro 1
some event
your actions...
disable macro 1
enable macro 2


macro 2 <--- disable this macro manually after you make the macro.
some event
enable macro 1
disable macro 2


what will happen here is the second macro is going to consume the second event and not let the first macro run when that second event comes in.

This is the ideal solution because if you clear pending events it clears the whole event buffer. so if there is an event in there other then the one you want to clear out.. you will lose that event also.
If you like the work I have been doing then feel free to Image

Crowley
Posts: 27
Joined: Sat Dec 21, 2019 6:05 am

Re: Cancel / stop macro if another event happens.

Post by Crowley » Mon Dec 23, 2019 12:59 pm

Thanks for the suggestion, but this does not work.


macro 1
System.Device.Removed.SoundDevice.NVIDIA High Definition Audio (event 1)
your actions... -> This always runs, event in macro 2 does not disable it.
disable macro 1
enable macro 2


macro 2 <--- disable this macro manually after you make the macro.
System.Device.Attached.SoundDevice.NVIDIA High Definition Audio (event 2)
enable macro 1
disable macro 2


I don't really see how this could work either, event 2 can be logged second or two after event 1 when switching display mode. And I can't use wait in the first macro since no events get logged when eventghost is waiting.

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Cancel / stop macro if another event happens.

Post by kgschlosser » Mon Dec 23, 2019 6:20 pm

zip up your save file and PM it to me. This way I know exactly what we are dealing with. I will make the changes needed and then send it back to you..
If you like the work I have been doing then feel free to Image

Crowley
Posts: 27
Joined: Sat Dec 21, 2019 6:05 am

Re: Cancel / stop macro if another event happens.

Post by Crowley » Mon Dec 23, 2019 11:42 pm

I PM'd you my config, the part I tried to copy from your suggestion is the very last folder on there.

I guess I'll try to explain in more detail what I'm trying to do.

So, like I said in the MCE plugin topic, sometimes inputs from my remote get lost on the PC receiver from my Logitech harmony remote. Most of the time it's no big deal, I just press the button again. However, when I turn off the system, the Logitech remote resets to a basic state without any activity. When I turn off my system, I send a specific command to the PC, that shuts off Kodi and some other software and actions. But if this command gets lost on the PC, my projector shuts off, my receiver shuts off, but PC software does not.

So, I'm trying to make a fail safe. Since eventghost does see the receiver going off, if it misses the "off" command (aspect MCE command in my case) I want it to turn off the PC software.

The problem comes from the fact that when I change the display mode on the receiver, like 59hz -> 60hz etc, the receiver briefly disconnects. It comes back again pretty soon, a few seconds at the most, but the script "off" still runs. I'd like to run it only when the receiver turns off and stays off more than a few seconds and if the "off command" was missed.

I hope I'm making sense, and if it cannot be done because of the limitations of eventghost, that's fine. Still, thanks for the support!

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Cancel / stop macro if another event happens.

Post by kgschlosser » Tue Dec 24, 2019 1:44 am

I have not found a limit to what EG can do.....

I am running 4 HTPC's a server, projector, 4TV's lights, locks, security, security cameras, 3 furnaces, 2 sump pumps.. a plethora of other sensors. remotes all over the place. every room is able to receive IR commands, touch panels. the list goes on and on.. all from 1 running copy of EG,


I know exactly what you are talking about with the AVR and the disconnect I had the same issue with a samsung TV.. it is an annoyance.. you will want to use the timer plugin.. start the timer when the AVR goes off. set the timer for say 5 seconds.. after the 5 seconds has expired an event will get triggered.. react to that event to close things down as needed.. if the AVR reconnects before that timer expires simply cancel the timer

I would like you to do the work on this. I think it may be beneficial for you. the timer plugin comes pre packaged with EG.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Cancel / stop macro if another event happens.

Post by kgschlosser » Tue Dec 24, 2019 6:10 am

i took a look at your config file.. You do know there is a Kodi plugin available correct???

check the plugins thread for XBMC you will find it there.

I also noticed a large amount of jumping about in your script.. You might now want to do that too much.. reason is because it is hard to follow what is happening when you use them it is just going to lead to a cleaner tree and one that is far easier to diagnose what is happening. you have to trust me on that one.. I have an ENORMOUS tree and have had to write the thing over on more then one occasion.. and those jumps cause a lot of extra work when trying to figure out what is happening..

I am pretty confident that the Timer plugin is going to fix your issue.. we can also write a script that will bind a callback so when the event occurs it can be consumed if necessary and also stop the timer.

there are several ways to go about taking care of your specific problem.. I am actually going to do a write up in the coding corner section on how to bind to an event to be able to react upon it before it runs any macros..
If you like the work I have been doing then feel free to Image

Crowley
Posts: 27
Joined: Sat Dec 21, 2019 6:05 am

Re: Cancel / stop macro if another event happens.

Post by Crowley » Tue Dec 24, 2019 8:55 am

Ok, thanks for the support I will keep trying tinkering with it.

I use Logitech Harmony and MCE receiver, most commands are read directly by Kodi, and for few buttons that Kodi does not understand I emulate keyboard with eventghost, and this works great combined with Kodi keymap editor. I wonder what benefit would XBMC plugin bring? This way navigation commands do not need any "middleman" so to speak.

The reason I use jumps is so that I don't have to copy and paste the exact same thing multiple times, I try to make fail-safes and such where specific conditions can launch macros that are already bound to a button event.

User avatar
kgschlosser
Site Admin
Posts: 5508
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Cancel / stop macro if another event happens.

Post by kgschlosser » Tue Dec 24, 2019 4:31 pm

take a look at the kodi plugin (xbmc) you might find that it can do some useful things for ya
If you like the work I have been doing then feel free to Image

Post Reply