New Plugin: USB IR Remote Receiver

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Posts: 2
Joined: Sat May 08, 2010 8:28 am

New Plugin: USB IR Remote Receiver

Post by Portisch » Sat May 08, 2010 8:36 am


I have created a new universal multiprotocol USB IR receiver: ... e_Receiver

The topic is in german but the download includes an english description.

Now I'm trying to write my first EventGhost plugin:

Code: Select all

EventGhost Plugin for the `USB IR Remote Receiver`__.

import eg

    name = "USB IR Remote Receiver",
    author = "Portisch",
    version = "0.0.1",
    kind = "remote",
    description = __doc__

import ctypes
import os
from ctypes import *

class USBIRRemoteReceiver(eg.PluginBase):

    def ReceivedIRCode(self, Protocol, Address, Command, Flags):
        #print "Received Protocol: " + Protocol
        #print "Received Address: " + Address
        #print "Received Command: " + Command
        #print "Received Flags: " + Flags
        self.TriggerEvent("Protocol: " + Protocol + ", Address: 0x" + Address + ", Command: 0x" + Command)

    def __init__(self):
        print ("USBIRRemoteReceiver: Plugin gets loaded.")
        print ("USBIRRemoteReceiver: Actual path: " + os.path.dirname(os.path.abspath(__file__)))
            print ("USBIRRemoteReceiver: Try to load ''USB_IR_Remote_Receiver.dll''")
            self.dll = ctypes.windll.LoadLibrary(os.path.dirname(os.path.abspath(__file__)) + ("\USB_IR_Remote_Receiver.dll"))
            print ("USBIRRemoteReceiver: USB_IR_Remote_Receiver.dll found and loaded!")
            self.dll.PluginName.restype = c_char_p
            print ("USBIRRemoteReceiver: DLL Plugin Name: " + self.dll.PluginName())            
            self.dll.Version.restype = c_char_p
            print ("USBIRRemoteReceiver: DLL Plugin Version: " + self.dll.Version())
            self.dll.Copyright.restype = c_char_p
            print ("USBIRRemoteReceiver: DLL Plugin Copyright: " + self.dll.Copyright())
            self.dll.Initialized = False
            raise self.Exceptions.FileNotFound            
        print ("USBIRRemoteReceiver: Init of USB IR Remote Receiver finished!")

    def __start__(self, myString):
        #print ("USB IR Remote Receiver is started")
        # funtion prototype
        prototype = WINFUNCTYPE(None, c_char_p, c_char_p, c_char_p, c_char_p)
        # create callback function            
        self.MyIRCallback = prototype(self.ReceivedIRCode)        
        self.dll.Initialized = True
        print ("USBIRRemoteReceiver: DLL got initialized")

    def __stop__(self):
        #print ("USB IR Remote Receiver is stopped.")

    def __close__(self):
        print ("USBIRRemoteReceiver: USB_IR_Remote_Receiver.DLL is unloaded!")        
        #print ("USB IR Remote Receiver is closed.")

    def Configure(self, myString=""):        
        panel = eg.ConfigPanel()     
        ShowSettingsButton = wx.Button(panel, id=-1, label='Show Settings/Option Dialog\n\n(This Dialog can only be shown if the plugin got initialized!)', pos=(8, 8), size=(175, 28))
        ShowSettingsButton.Bind(wx.EVT_BUTTON, self.ShowSettingsButtonClick)
        if self.dll.Initialized:
            print ("USBIRRemoteReceiver: Trying to show Settings/Options dialog")
            print ("USBIRRemoteReceiver: DLL is not initialized, can't show dialog")
        panel.sizer.Add(ShowSettingsButton, 1, wx.EXPAND)           
        while panel.Affirmed():

    def ShowSettingsButtonClick(self,event):
            self.dll.ShowSettings.restype = None
            print ("USBIRRemoteReceiver: Error showing Settings/Options dialog")
Now I have the problem, that I need the Configure function to show the DLL-Settings/Options dialog.
Is there a more simple way to show the dialog without the panel when I click with the right mouse on the Plugin -> Configure?

Also I can't remove the def __start__(self, myString):,
than I will get the error too many arguments.

Please help tp finish my EventGhost plugin.
The EventGhost plugin can be tested without hardware. Just copy the "USB_IR_Remote_Receiver.dll" in the same folder where the script is located.


Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: New Plugin: USB IR Remote Receiver

Post by Bartman » Sat May 08, 2010 8:44 am

AFAIK the panel always show.

You get the too many arguments error because you set an empty string as the result and this string gets passed to the start method.
look at the timer plugin to circumvent this.

Posts: 2
Joined: Sat May 08, 2010 8:28 am

Re: New Plugin: USB IR Remote Receiver

Post by Portisch » Sun May 09, 2010 6:16 pm

Thx for your help!

I finished now the plugin:

Project: USB IR Remote Receiver (German, English description is included in the download of the project)

The plugin is attached, I don't know if this would be added to EventGhost!?

Plugin for USB IR Remote Receiver
(217.96 KiB) Downloaded 294 times

Experienced User
Posts: 62
Joined: Mon Mar 29, 2010 10:31 am

Re: New Plugin: USB IR Remote Receiver

Post by brand10 » Wed Jun 08, 2011 11:14 am

Hello Portisch,

I am very interested in your USB IR Receiver project. Is it possible to get a ready built up receiver? I could build it by myself, but i dont have a programmer for the microcontroller :( Im from Germany.

Best Regards

Post Reply