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.
Help with writing a plugin
Help with writing a plugin
Hi I'm trying to figure out how to read the string of the last triggered event from within a plugin. I'm new to python but I've been using EventGhost for about a year to operate my home theater system.
I've been poking around in EventGhostEvent.py and I can see that the event string is there by printing it.
def Execute(self):
#start = clock()
print "eventghostevent.py:",self.string
Thanks in advance for the help
I've been poking around in EventGhostEvent.py and I can see that the event string is there by printing it.
def Execute(self):
#start = clock()
print "eventghostevent.py:",self.string
Thanks in advance for the help
Re: Help with writing a plugin
Thanks very much, that worked!
I'd like to ask you another question in the hopes that you can get me going in the right direction ... how can I modify the Event Ghost: Trigger Event action to add a field where i could specify a text string to be inserted into the payload of the triggered event?
Thanks again!
I'd like to ask you another question in the hopes that you can get me going in the right direction ... how can I modify the Event Ghost: Trigger Event action to add a field where i could specify a text string to be inserted into the payload of the triggered event?
Thanks again!
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Help with writing a plugin
I think the board is getting more and more messed up with Q&A's in the wrong sections, its becoming a tutti-frutti and it will soon be impossible to see a structure. Please keep this type of postings in the dedicated "Coding Corner".
Every time you find need for a posting, think carefully where it belongs best
Best regards, Walter
Every time you find need for a posting, think carefully where it belongs best
Best regards, Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
Re: Help with writing a plugin
Actually, now that he mentions it, why there is no payload field in the "Trigger Event" action's config dialog? I think the textfield for it should be there, but marked optional.
The attached file has a configuration option for payload, replace EventGhost\plugins\EventGhost\__init__.py with this one if you want to test it.
-jinxdone
The attached file has a configuration option for payload, replace EventGhost\plugins\EventGhost\__init__.py with this one if you want to test it.
-jinxdone
- Attachments
-
- __init__.py
- modified EventGhost\plugins\EventGhost\__init__.py
- (16.25 KiB) Downloaded 149 times
Re: Help with writing a plugin
Hey Thanks for the file attachment ... that is just what was looking for but I seem to be getting some errors ... I'm running 0.3.7 r1194 and I've attached a config file.
I'd be happy to post in the other section. Do I need to start a new thread?
This error when a sequence clear action occurs:
Error in Action: "Trigger event "sequence.clear""
Traceback (most recent call last) (1194):
File "C:\Program Files\EventGhost\eg\Classes\ActionBase.py", line 168, in CallWrapper
File "C:\Program Files\EventGhost\plugins\EventGhost\__init__.py", line 435, in __call__
File "C:\Program Files\EventGhost\eg\Utils.py", line 183, in ParseString
TypeError: object of type 'float' has no len()
This error when I try to reconfigure an existing trigger event
Traceback (most recent call last):
File "EventGhost.pyw", line 31, in <module>
File "C:\Program Files\EventGhost\eg\__init__.py", line 101, in Main
eg.Tasklet(eg.app.MainLoop)().run()
File "C:\Program Files\EventGhost\eg\Classes\TaskletDialog.py", line 41, in ProcessingTask
self.Configure(*args, **kwargs)
File "C:\Program Files\EventGhost\eg\Classes\ConfigDialog.py", line 126, in Configure
self.item.Configure(*args)
File "C:\Program Files\EventGhost\eg\Classes\ActionItem.py", line 107, in Configure
return self.executable.Configure(*args)
File "C:\Program Files\EventGhost\plugins\EventGhost\__init__.py", line 456, in Configure
eventPayloadCtrl = panel.TextCtrl(eventPayload, size=(250, -1))
File "C:\Program Files\EventGhost\eg\Classes\ControlProviderMixin.py", line 52, in TextCtrl
return wx.TextCtrl(self, -1, value, pos, size, style, validator, name)
File "wx\_controls.pyc", line 1736, in __init__
TypeError: String or Unicode type required
Traceback (most recent call last):
File "C:\Program Files\EventGhost\eg\Classes\MainFrame\__init__.py", line 344, in FuncWrapper
func()
File "C:\Program Files\EventGhost\eg\Classes\MainFrame\__init__.py", line 868, in OnCmdConfigure
eg.UndoHandler.Configure().Try(self.document)
File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 41, in Try
eg.Tasklet(self.Do)(item).run()
TaskletExit
I'd be happy to post in the other section. Do I need to start a new thread?
This error when a sequence clear action occurs:
Error in Action: "Trigger event "sequence.clear""
Traceback (most recent call last) (1194):
File "C:\Program Files\EventGhost\eg\Classes\ActionBase.py", line 168, in CallWrapper
File "C:\Program Files\EventGhost\plugins\EventGhost\__init__.py", line 435, in __call__
File "C:\Program Files\EventGhost\eg\Utils.py", line 183, in ParseString
TypeError: object of type 'float' has no len()
This error when I try to reconfigure an existing trigger event
Traceback (most recent call last):
File "EventGhost.pyw", line 31, in <module>
File "C:\Program Files\EventGhost\eg\__init__.py", line 101, in Main
eg.Tasklet(eg.app.MainLoop)().run()
File "C:\Program Files\EventGhost\eg\Classes\TaskletDialog.py", line 41, in ProcessingTask
self.Configure(*args, **kwargs)
File "C:\Program Files\EventGhost\eg\Classes\ConfigDialog.py", line 126, in Configure
self.item.Configure(*args)
File "C:\Program Files\EventGhost\eg\Classes\ActionItem.py", line 107, in Configure
return self.executable.Configure(*args)
File "C:\Program Files\EventGhost\plugins\EventGhost\__init__.py", line 456, in Configure
eventPayloadCtrl = panel.TextCtrl(eventPayload, size=(250, -1))
File "C:\Program Files\EventGhost\eg\Classes\ControlProviderMixin.py", line 52, in TextCtrl
return wx.TextCtrl(self, -1, value, pos, size, style, validator, name)
File "wx\_controls.pyc", line 1736, in __init__
TypeError: String or Unicode type required
Traceback (most recent call last):
File "C:\Program Files\EventGhost\eg\Classes\MainFrame\__init__.py", line 344, in FuncWrapper
func()
File "C:\Program Files\EventGhost\eg\Classes\MainFrame\__init__.py", line 868, in OnCmdConfigure
eg.UndoHandler.Configure().Try(self.document)
File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 41, in Try
eg.Tasklet(self.Do)(item).run()
TaskletExit
- Attachments
-
- payloads-11-17-2009.xml
- (125.96 KiB) Downloaded 106 times
Re: Help with writing a plugin
Both problems are caused by the old config tree being incompatible with the modified action because I added the option for payload, it adds a new variable which did not exist before. If you recreate all the old "Trigger Event" actions and it should be fine.
-jinxdone
-jinxdone
Re: Help with writing a plugin
Hi JinxDone, the patch you sent me works great with a simple plugin that I'm experimenting with. Next for me is to rewrite everything and put a few more features into the plugin.
I'm wondering though, do you plan to include the patch in the next release of eventghost or should I look into making the trigger event with optional payload a separate plugin?
I'm wondering though, do you plan to include the patch in the next release of eventghost or should I look into making the trigger event with optional payload a separate plugin?
Re: Help with writing a plugin
I think it should be there by default.
But, just to make it a little bit more user-friendly, in the action config dialog there should be a "Use payload" checkbox for enabling / disabling the payload textfield(so when disabled the textfield would be greyed out). This way it would be clear to everybody it's optional, especially thinking about new users here..
In the meantime you could just as well use a python script to trigger the event instead of using the action. Like so..
But, just to make it a little bit more user-friendly, in the action config dialog there should be a "Use payload" checkbox for enabling / disabling the payload textfield(so when disabled the textfield would be greyed out). This way it would be clear to everybody it's optional, especially thinking about new users here..
In the meantime you could just as well use a python script to trigger the event instead of using the action. Like so..
Code: Select all
eg.TriggerEvent("MyEvent", "payload")Re: Help with writing a plugin
I'm using the payload as a way to group commands into one macro name then route them to various sources
main.room1 (up)
main.room1 (down)
main.room1 (left)
main.room1 (right)
a macro captures main.room1
then my plugin renames the event and appends the payload and triggers a new event
main.source1.up
I would place four of my plugin entries and enable or disable the one I need in my program tree depending on which source is selected ... then they'd be renamed as required
main.source2.up
main.source3.up
then another sub tree captures requests from the 2nd room and renames them as required
main.room2 (up)
main.source1.up
main.source2.up
this makes it easier to write an event tree for my system which has two rooms and three shared sources.
Or is there another way to do this that I don't know about?
It'll take me some spare time to rewrite everything. But in the future I'll need the event payload whether it's part of eventghost or an extra plugin or whether I modify the __init.py__ file everytime I download a new version of eventghost.
main.room1 (up)
main.room1 (down)
main.room1 (left)
main.room1 (right)
a macro captures main.room1
then my plugin renames the event and appends the payload and triggers a new event
main.source1.up
I would place four of my plugin entries and enable or disable the one I need in my program tree depending on which source is selected ... then they'd be renamed as required
main.source2.up
main.source3.up
then another sub tree captures requests from the 2nd room and renames them as required
main.room2 (up)
main.source1.up
main.source2.up
this makes it easier to write an event tree for my system which has two rooms and three shared sources.
Or is there another way to do this that I don't know about?
It'll take me some spare time to rewrite everything. But in the future I'll need the event payload whether it's part of eventghost or an extra plugin or whether I modify the __init.py__ file everytime I download a new version of eventghost.
Re: Help with writing a plugin
Have you considered doing the logic of your macro/event triggering system with a python script? This way you only need to trigger the one macro, which then does something based on the event/payload value or whatever you need it to do.
Just suggesting because this is staring to sound like it is getting a bit too complex to be easily made using just the config tree.
Just suggesting because this is staring to sound like it is getting a bit too complex to be easily made using just the config tree.