I'm not sure if this can be done (searched the forum but couldn't find an answer). I would like to execute an eventghost macro from a Python script. Currently I'm raising an event with python which triggers my macro.
eg.TriggerEvent("SetSageExclusive", payload=None, prefix="Call", source=eg)
Is there a way to just call the macro directly similar to a Jump via Python?
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.
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.
Call a Macro Directly From a Python Script?
Re: Call a Macro Directly From a Python Script?
You can use the Jump action from Python.SDeGonge wrote:Is there a way to just call the macro directly similar to a Jump via Python?
I just posted this in an other thread should work for you.
jonibIf you need a pointer to a macro just create for example a Jump action to the macro, then copy that action from EventGhosts config tree and paste to a text document. now you see the syntax for the Jump action, including a number to access the specific macro that you can store in a variable.
Re: Call a Macro Directly From a Python Script?
Thanks for the tip. That copy/paste trick is pretty cool, however, I still don't know how to go from this to the proper python syntax. Forgive me - I just got started with eventghost and python so I'm still struggling to do the simplest things.jonib wrote:You can use the Jump action from Python.SDeGonge wrote:Is there a way to just call the macro directly similar to a Jump via Python?
I just posted this in an other thread should work for you.jonibIf you need a pointer to a macro just create for example a Jump action to the macro, then copy that action from EventGhosts config tree and paste to a text document. now you see the syntax for the Jump action, including a number to access the specific macro that you can store in a variable.
Re: Call a Macro Directly From a Python Script?
Unfortunately I missed two things. You need to add a eg.plugins. before the action when run from python.
So eg.plugins.EventGhost.NewJumpIf should work when run from the Python command.
The second thing I missed is the XmlIdLink(1857) part unfortunately I can't figure out what needs to be done to make it work in a Python script.
So my solution is only a partial one, sorry.
jonib
So eg.plugins.EventGhost.NewJumpIf should work when run from the Python command.
The second thing I missed is the XmlIdLink(1857) part unfortunately I can't figure out what needs to be done to make it work in a Python script.
So my solution is only a partial one, sorry.
jonib
Re: Call a Macro Directly From a Python Script?
Did some searching and couldn't find anything to help with this problem. Thanks anyway for your quick response.jonib wrote:Unfortunately I missed two things. You need to add a eg.plugins. before the action when run from python.
So eg.plugins.EventGhost.NewJumpIf should work when run from the Python command.
The second thing I missed is the XmlIdLink(1857) part unfortunately I can't figure out what needs to be done to make it work in a Python script.
So my solution is only a partial one, sorry.
jonib
Re: Call a Macro Directly From a Python Script?
maybe this would work, as an alternative... set a global variable in the script, have the Macro trigger based on the variable value.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Call a Macro Directly From a Python Script?
I don┬┤t know much about Python. Here are some WILD guesses: if you look in this file: \EventGhost_0.4.1.r1568_Source\eg\Classes\ActionItem.py, you can find:
My take is that "XmlIdLink" is defined as some kind of anonymous function related to TreeLink.CreateFromArgument(self, id). Problem is that the first parameter ("self") is a pointer to an instance of an object. And I don┬┤t know where to find that object, or which value I can replace it with.
So my last guess is that XmlIdLink(some number) could be replaced with: eg.plugins.EventGhost.NewJumpIf(eg.Classes.TreeLink.TreeLink.CreateFromArgument(some object, 2541), 2, False)
Please don┬┤t forget that this is WILD WILD guesses!
Code: Select all
def SetArgumentString(self, argString):
try:
args = eval(
'returnArgs(%s)' % argString,
eg.globals.__dict__,
dict(
returnArgs=lambda *x: x,
XmlIdLink=lambda id: TreeLink.CreateFromArgument(self, id),
....My take is that "XmlIdLink" is defined as some kind of anonymous function related to TreeLink.CreateFromArgument(self, id). Problem is that the first parameter ("self") is a pointer to an instance of an object. And I don┬┤t know where to find that object, or which value I can replace it with.
So my last guess is that XmlIdLink(some number) could be replaced with: eg.plugins.EventGhost.NewJumpIf(eg.Classes.TreeLink.TreeLink.CreateFromArgument(some object, 2541), 2, False)
Please don┬┤t forget that this is WILD WILD guesses!
