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.

Help writing a plugin

If you have a question or need help, this is the place to be.
Post Reply
nightrader_
Posts: 13
Joined: Mon Nov 05, 2007 12:19 am

Help writing a plugin

Post by nightrader_ »

Hello

First let me say EventGhost is AMAZING.

Now, I'm trying to write a EG plugin to generate RecordingStarted and RecordingStopped events from SageTV Status plugin.

The plan is to use the SageTV plugin 'External Status Monitor Interface', which sends out the current status when a tcp connection is opened on the configured port. The status is sent as a series of strings.
See this link for programming info on the Status plugin http://tools.assembla.com/sageplugins/w ... sInterface


I have managed to create the skeleton code for the plugin and I have the Config dialog (for Host Address, Host Port, Polling Interval). I also have everything setup to run EC from source code.

So my problem is, this is the first that I have ever played with python. I know what I need to get done in the plugin, I just don't know how to do it in python.

I need to start a timer in the __start__, (and stop it in the __stop__), then in the timer event I need to connect to the Status plugin and read the strings, then decode the strings and decide if a capture device has changed status, if so fire the correct event with the devicename, showname, etc, in the payload.

I've written a delphi app that talks to the sagetv status plugin, so I'm not completely in the dark, but pascal is a long way from python, so all help is greatly appreciated.

Link to thread on Status plugin http://forums.sagetv.com/forums/showthread.php?t=8757



Nightrader
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Help writing a plugin

Post by Bitmonster »

So the STVS plugin doesn't inform the connected client applications of a change automatically and you have to poll the information continuously? That's no good practice actually.

You can do such polling with a threading.Thread() like it is shown in the plugin tutorial:
http://www.eventghost.org/wiki/Writing_ ... erm_events
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
nightrader_
Posts: 13
Joined: Mon Nov 05, 2007 12:19 am

Re: Help writing a plugin

Post by nightrader_ »

Bitmonster wrote:So the STVS plugin doesn't inform the connected client applications of a change automatically and you have to poll the information continuously? That's no good practice actually.
Yes, you are correct, but I did not write it. I do think it servers it's original purpose OK, (was created for the small LCD's is some HTPC cases.)
Bitmonster wrote:You can do such polling with a threading.Thread() like it is shown in the plugin tutorial:
http://www.eventghost.org/wiki/Writing_ ... erm_events
Thanks, I believe that will point me in the right direction.

Could you point me to some string handle examples (I need to break out the strings from the STV plugin).

BTW, THANKS for the quick reply.

Nightrader
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Help writing a plugin

Post by Bitmonster »

Well, first you need a socket connection established. The NetworkSender plugin should give an example how to do that.

For string handling I would suggest to consult the Python docs:
http://docs.python.org/lib/string-methods.html
split() and strip() you need mostly I guess.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
nightrader_
Posts: 13
Joined: Mon Nov 05, 2007 12:19 am

Re: Help writing a plugin

Post by nightrader_ »

Bitmonster wrote:Well, first you need a socket connection established. The NetworkSender plugin should give an example how to do that.

For string handling I would suggest to consult the Python docs:
http://docs.python.org/lib/string-methods.html
split() and strip() you need mostly I guess.
Yes, I have looked at both the NetworkSender and the NetworkReceiver, I think should be all I need for the TCP stuff.

I should be able to figure most of it out. Right now I'm looking at the thread class in the python docs :). Once I get the polling thread working I will add in the TCP code and work on getting a handle on the strings returned from the socket.

Thanks again for the VERY QUICK reply. I have to go to work, but I will be playing with this more tonight. I'm sure I will have more noobie questions for ya then. :D

Nightrader
nightrader_
Posts: 13
Joined: Mon Nov 05, 2007 12:19 am

Re: Help writing a plugin

Post by nightrader_ »

Update:

I did not get much time to play last night, but I was able to get the socks code to talk to the SageTV server and get the current status and stick it in a list. The Thread code you referred me to worked great.

Now I just need to parse the strings and decide if the status has changed.

Thanks for all the help. :mrgreen:
I should have this working very soon.

Nightrader
Attachments
here is what the output looks like
here is what the output looks like
nightrader_
Posts: 13
Joined: Mon Nov 05, 2007 12:19 am

Re: Help writing a plugin

Post by nightrader_ »

OK, done, the SageTVEvents plugin is done (only tested by me) :D .

The following events are supported:
NowPlaying :note this is only supported if your connecting to a SageTVClient or you are using your server as a client also.
RecordingStart
RecordingStop

I load the "payload" with a string containing all the show and device info. so now I have a few questions.
1. Where do I upload the source code for review/addition?
2. in EG, I have a macro setup to start a program when then RecordingStop event is received, how do I get to the "payload" into the Start a Program action?

Thanks,
Nightrader
Post Reply